Jump to content

API - Custom Fields (Add Client / Get Client)


Erik

Recommended Posts

Can someone come to the rescue here?

 

I have been able to successfully ADD a client and GET a client's details with the API, but I have NOT been able to pass or view the custom fields of a client. The API docs mention it needs to be "a base64 encoded serialized array of custom field values" but I haven't been able to wrap my mind around it.

 

:arrow: Suppose I have three custom fields "test1, test2, test3", how would the line of code be to be included in the 1) Add a client (to insert the fields) and 2) Get a Client's details (to retrieve the fields). I am willing to pay at this point.

 

Thanks in advance!

Link to comment
Share on other sites

This is how to insert Custom Fields using ADD CLIENT (API)

 

36, 37, 38 - This is the actual "ID" of each custom field I want to add values to. I have a lot of custom fields. Didn't know I had to use these, but alas, it was the only way I got them to work.

 

$value1, $value2, $value3 - The actual values I want to insert into the custom fields.

 

$postfields["customfields"] = base64_encode(serialize(array( "36" => $value1, "37" => $value2, "38" => $value3)));

 

:arrow: Now.. I just need to figure out how to RETRIEVE this information during a GET CLIENT DETAILS.. anyone?

Link to comment
Share on other sites

Been trying to crack this all morning. I'm beginning to think I found one of the API's limits (retrieving custom field values), considering the data for the custom fields is stored in another MySQL table altogether. This may indeed be over-reaching to think its possible and will have to resort to just using a MySQL query to get it. :|

Edited by Erik
Link to comment
Share on other sites

Wow, ok.. sorry for the million posts.. last one as I figured out how to use the API to retrieve custom fields. Phew!

 

Even though you have to specify the exact customfield ID (see my post above) to INSERT values, getting them out is not the same. Apparently, it uses the customfield display order (?) (and you don't have to decode them!)

 

For instance, if I have custom fields like so:

 

Custom Field Name - Display Order

Test1 - Display Order 0

Test6 - Display Order 10

Test3 - Display Order 20

 

Then the exact values for the API to retrieve is:

customfields1 - Test1

customfields2 - Test6

customfields3 - Test3

 

They are in order of display order.. not the display order values (10,20,etc..) but the exact order they line up starting with 1,2,3

 

Go figure.. just thought I'd share

Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated