Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Mohana Gopal Selvam
    How to get the custom Yes/No field value using CPHPAnswered
    Topic posted November 30, 2015 by Mohana Gopal SelvamSilver Crown: 22,500+ Points 
    863 Views, 22 Comments
    Title:
    How to get the custom Yes/No field value using CPHP
    Content:

    Hi Gurus,

    We have created the custom Yes/No field in Incident object. We have to fetch the value in CPM. I have tried the following codes. But it returns null value for all variables. Please let me know the correct code. 

         $sendsms = $incident->CustomFields->c->send_sms;
         $sendsmslookupname = $incident->CustomFields->c->send_sms->LookupName;
         $sendsmsvalue = $incident->CustomFields->c->send_sms->Value;
         $sendsmslookuname = $incident->CustomFields->c->send_sms->Name;
         print($sendsms);
         print($sendsmslookupname);     
         print($sendsmslookvalue);
         print($sendsmsname);

    Thanks,

    Mohan

    Best Comment

    Barrilito van Dijk

    Hi Mohana,

    I think your first option is spot on ($sendsms = $incident->CustomFields->c->send_sms), that should be working.

    @Allan: what was the defect precisely about? In what release is it and will it be patched?

    It is good if there are workarounds for things and it is certainly appreciated to see people get involved to give some hints for a workaround, but things like this should have no workaround, this is such basic stuff, if that comes into a defect status I feel there should be some prio on fixing it asap in some kind of patch. I think Mohana prefers to spend time on making nice OSC solutions instead of re-inventing CPHP again to do a basic querywink

     

     

    Comment

    • Allan Schrum

      Above you mentioned that $inc->CustomFields->c->send_sms->ID did not work. How? Have you tried:

      $sendsms = $inc->CustomFields->c->send_sms->LookupName;

      If this is a menu then the ID and LookupName will be defined.

      Regards,

      -Allan

    • Mohana Gopal Selvam
      Hi Allan,
      
      Sendsms is the Yes/No field. I have tried all the options. But no luck. We heard it is the product bug.
      
      @BvD,
      Thanks for your time.
      
      Thanks,
      Mohan
      
    • Barrilito van Dijk

      No problem Mohana!

    • Ron Riddle

      Hello Mohan,

      I believe if you cast the return value from that property to an int, you should see zero printed.

      $sendsms = (int)$inc->CustomFields->c->send_sms;

      print($sendsms);

      Regards,

      Ron

    • Chris Story

      I am having the same issue as Mohana.  I am attempting to use Connect PHP to read the value of a Yes/No custom field and get the following results which prevent me from deciphering the difference between a result of "No" or "No Value."

      print_r($contact->CustomFields->c->smoker,true);

      Yes => 1

      No => No Value

      No Value => No Value

      @Oracle Has this bug be put on a schedule yet to be fixed?

       

      Has

    • Barrilito van Dijk

      Hi Chris,

      Why don't just send a service request to Oracle directly and state it as a software defect?

      Regards.

    • Bastiaan van der Kooij

      you can check the difference between the No Value and 0 by checking the type;

      field == 1 > true;
      gettype(field) == boolean && field == 0 > false;
      gettype(field) == null > no value;