Skip Navigation
Retrieving NamedID values from custom field
Answer ID 7461   |   Last Review Date 10/31/2018

How do I retrieve NamedID values from a custom field?


Connect PHP API (All Versions)


To retrieve NamedID values from a custom field, refer to the following example.

This example assumes you have prior knowledge of the Connect PHP API

  • Retrieve Metadata from parent object
    • $acct = RNCPHP\Account::getMetadata();
  • Get type_name property value of custom fields object
    • $shifts = $acct->CustomFields->type_name;
  • Retrieve Metadata of type_name
    • $shifts = $shifts::getMetadata();
  • Get type_name value of object c
    • $shifts = $shifts->c->type_name;
  • Retrieve named_values of custom field in question
    • Custom field name = shift
    • $shifts = $shifts::getMetadata()->shift->named_values;

The named_values will be returned as an array of objects. To display them on the page use a foreach loop, such as the following, if more than one object is present.

foreach($shifts as $s) {
   echo $s->ID;

   echo $s->LookupName;