Erik Posted August 29, 2011 Share Posted August 29, 2011 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! 0 Quote Link to comment Share on other sites More sharing options...
Erik Posted August 29, 2011 Author Share Posted August 29, 2011 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? 0 Quote Link to comment Share on other sites More sharing options...
Erik Posted August 29, 2011 Author Share Posted August 29, 2011 (edited) 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 August 29, 2011 by Erik 0 Quote Link to comment Share on other sites More sharing options...
Erik Posted August 29, 2011 Author Share Posted August 29, 2011 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 0 Quote Link to comment Share on other sites More sharing options...
tobbit Posted February 23, 2012 Share Posted February 23, 2012 Hi Erik, Just wanted to say thanks - I'd been scratching my head for quite a while about inserting custom fields via the API. Works a treat to use the value ID of the custom field ! Kindest Regards, Toby. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.