CustomFields JSON PHP

Tagged:

Currently contains 7 posts

Avatar

July 10, 2019 14:54

hirenexus

I am trying to pull the value of the candidate custom field of Social_LinkedIn but can’t figure out how to set the value of this field to a PHP variable. I’ve tried $LinkedIn = $response→CustomFields→Social_LinkedIn; but that did not work.

Avatar

July 10, 2019 16:11

Jarrid-PCRecruiter

You’ll want to use the PUT /candidates/{CandidateId} endpoint to update an existing record’s value using the class CustomField(FieldName: string, FieldType: string, Values: Array[string]). You can use GET to take a look at the examples of a record you know has this data filled out.

Avatar

July 15, 2019 14:01

hirenexus

I’m using GET on /candidates/{CandidateId} and the response is this:

“CustomFields”: [
{
“FieldName”: “Social_LinkedIn”,
“FieldType”: “NoAction”,
“Values”: [
“https://www.linkedin.com/in/suzannezorrilla”
]
},

My question is, how do I use PHP to get the value of the Values field? The structure of the data in CustomFields is totally different than predefined fields.

Avatar

July 15, 2019 18:01

Jarrid-PCRecruiter

To be honest I’m not a developer and don’t know PHP very well but the data is returned as an array because custom fields could have multiple values so if you treat the “Values” as an array. If that information isn’t helpful let me know and I’ll ask one of our development team members for more information.

Avatar

July 15, 2019 20:23

hirenexus

Thanks Jarrid, that actually helped send me down the right path. For anyone else wondering about this, I was able to get the value of the field using this:

$custom_fields = $response→CustomFields;
$LinkedIn = $custom_fields0→Values0;

$LinkedIn is the PHP variable that I display on the page using echo. Basically, because $response→CustomFields is an array, and then the values are an array, you have to designate which field in the array you want and then which value, in my case both were the first and only values in the array so zero is used. There may be a better way, but this worked for me. Thanks!

Avatar

July 15, 2019 20:23

hirenexus

“$LinkedIn = $custom_fields0→Values0;”

Avatar

July 15, 2019 20:24

hirenexus

it keeps making the zeros exponents. it should be this:

$LinkedIn = $custom_fields[ 0 ]→Values[ 0 ];

no spaces before or after the zeros.

Reply to thread