Add the custom field Value When create new contact

Hello Team,

I am not able to add contact’s with custom field value.

Below is my code:

$infusionsoft->setToken(unserialize($rowGetInfo[“token”]));

$arr[]=array(“id”=>84,“content”=>“fhggfjhgdsfjhgsdhfgsfgjhgdfjhsdgf”);

$contact = [
            ‘FirstName’ => ‘aaa’,
            ‘LastName’ => ‘zzz’,
            ‘Email’ => ‘aaavv@com.au’,
            ‘custom_fields’=>$arr
            ];

$infusionsoft->contacts(‘xml’)->add($contact);

but I’m getting an error field not found.

Fatal error: Uncaught fXmlRpc\Exception\FaultException: [NoFieldFound]No field found: Contact.custom_fields in /home/yupitcom/public_html/IS/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Exception/FaultException.php:32
Stack trace:
#0 /home/yupitcom/public_html/IS/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Parser/XmlReaderParser.php(373): fXmlRpc\Exception\FaultException::fault(Array)
#1 /home/yupitcom/public_html/IS/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Client.php(156): fXmlRpc\Parser\XmlReaderParser->parse(’<? xml version = "…’)
#2 /home/yupitcom/public_html/IS/vendor/infusionsoft/php-sdk/src/Infusionsoft/Http/InfusionsoftSerializer.php(28): fXmlRpc\Client->call(‘ContactService…’, Array)
#3 /home/yupitcom/public_html/IS/vendor/infusionsoft/php-sdk/src/Infusionsoft/Infusionsoft.php(451): Infusionsoft\Http\InfusionsoftSerializer->request(‘ContactService…’, ‘https://api.inf…’, Array, Object(fXmlRpc\Client))
#4 /home/yupitcom/public_html/IS/vendor/infusionsoft/php-sdk/src/Infusionsoft/Api/ContactService.php(13): Infusionsoft\Infusionso in /home/yupitcom/public_html/IS/vendor/infusionsoft/php-sdk/src/Infusionsoft/Http/InfusionsoftSerializer.php on line 34

Thanks

Hi @Sunny_Gajjar if you are trying to create the contact with just a single custom field, you can just do something simple like:

$contact = [
            "FirstName" => "aaa",
            "LastName" => "zzz",
            "Email" => "aaavv@com.au",
            "_customFieldName" => "custom field value"
];

You can find your custom field names here: https://YOUR_APP_NAME.infusionsoft.com/Admin/custom/popup/customFieldDetails.jsp?table=Contact. This is typically found under Admin > Settings. Here is a help article on creating custom fields that has more information about where they can be found.

1 Like

Thanks @Carlos_Ochoa

But I need to add value using custom field’s ID not using a custom field’s name.

No problem. The only way to use custom field id’s is with the REST API. Here are the docs for creating a contact in the REST API. The legacy XMLRPC API uses the custom field “database name”, at least for contact creation.

Is it possible when contact details update that time custom field value adding using id in XMLRPC API?

No, the XML-RPC does not use field Ids to identify custom fields.

Ok, Thank you @TomScott @Carlos_Ochoa