Setting options for multiple option fields with API

I am trying to set the option for a custom field using the API.

Actually my code works perfectly well when using a sandbox account:

I send options with array of ‘id’ and ‘label’ to set options. The ids are a ref to an entitiy in my system. On sandbox it works. I end up with

“options”: [
{
“label”: “Item 1”,
“id”: 14
},
{
“label”: “Item 2”,
“id”: 25
},
etc

But on live account pipedrive seems to replace my IDs with a incremental value meaning they no longer represent the entity they represent. So I end up with

“options”: [
{
“label”: “Item 1”,
“id”: 1
},
{
“label”: “Item 2”,
“id”: 2
},

So sandbox and live accounts seem to respond different to this one API call to update a custom field.

Any ideas?

Hi @timhyde
Welcome to the community :wave:
If I understood you correctly, the custom field options seem to be different in sandbox vs. live systems. Let me know if I got it right.

This is expected since the options might have the same text value but different IDs (varies from one account to the other)

Can you also add further details?

  • To which entity do these custom fields belong (deals/leads/contacts/…)?

  • Were you able to obtain the option IDs using the corresponding entities’ field? For instance, deals will have the dealFields endpoint Pipedrive API v1 Reference that can be used to get the option IDs

I’ve managed to work out what was going on. I think it was simply a fluke that it seemed to work in sandbox! You cannot use your own IDs, they are incremental.

Though you can effectively re-use IDs for field options that have previously existed on a multiple option field. This gives the allusion that it was working on sandbox.

Anyway I think I’ve got my head round it now. Thanks