Integrations and APIs for Service

Get Involved. Join the Conversation.


    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 
    864 Views, 22 Comments
    How to get the custom Yes/No field value using CPHP

    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;



    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




    • 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.



    • 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.
      Thanks for your time.
    • 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;




    • 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."


      Yes => 1

      No => No Value

      No Value => No Value

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



    • Barrilito van Dijk

      Hi Chris,

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


    • 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;