phpapiinfusionsoft

Infusionsoft retrieve all custom fields value for specific contact


I've been searching for this solution but haven't found one! I'm using Novak solution's Infusionsoft API.

What I'm trying to do is to get value of a custom field for specific contact. Lets say, I've a custom fields named _myCustomField with Yes/No value. I've 200 contacts in my list but only 15 contact has value 'Yes' for _myCustomField. Lets say I've another custom field _myCustomField2. If I run following query:

$contacts = Infusionsoft_DataService::query( new Infusionsoft_Contact(), array('_myCustomField' => '1') );

I get an array of 15 records, BUT if I print $contacts array then I don't see _myCustomField or _myCustomField2 there.

So, how do I get value for those two custom field inside my loop? Can someone help me with this?

Thanks!


Solution

  • The second parameter of the query method is only the filter and does not tell Infusionsoft that you also want to return any custom fields.

    You will want to add the custom fields first:

    $contact = new Infusionsoft_Contact();
    
    $contact->addCustomField('_myCustomField');
    $contact->addCustomField('_myCustomField2');
    
    $contacts = Infusionsoft_DataService::query( $contact, array('_myCustomField' => '1') );