Post

2 followers Follow
0
Avatar

Updating Custom Field Picklist items using API

How to I add / remove items from a picklist using the API?

I need to create a way to select users that are only members of a specific group for a custom action variable however there is no way to filter the list of available users so I thought I would create a custom picklist with the available options. Now I need to be able to update the list periodically to keep it current. The web interface does not offer that capability.

Can the API directly modify the structure of objects?

Josh Boutwell Answered

Please sign in to leave a comment.

8 comments

0
Avatar

That does seem to be the answer but I can't seem to make it work... I am still a novice and not really familiar with all the different methods.

I am sending a bulkexecute that includes:

{"url" : "/data/createAndRetrieve", "method": "POST", "body": {"entity": { "Id": "/C_Projectpicklisttest",
"pickups": [
{
"value": "test1",
"displayValue": "test2",
"description": "test3"
}]
}}}

I am getting a response:

"message": "Entity 'C_Projectpicklisttest' does not contain the field 'pickups'",

Any ideas? I feel like I am close but missing something obvious

Josh Boutwell 0 votes
Comment actions Permalink
0
Avatar

Sorry for the late response on this.
You just need to treat it as a regular object:

Post to this URL: /data/objects/C_Projectpicklisttest
The following value:
{
"id": "/C_Projectpicklisttest/NewValue"
}

Eyal Post 0 votes
Comment actions Permalink
0
Avatar

Worked like a charm!  All I had to do was update the method to PUT or DELETE.

 

Thanks!!

Josh Boutwell 0 votes
Comment actions Permalink
0
Avatar

Eyal,  I found one other new wrinkle.

 

Is there any way to define the manual order?   They seem to add to the top of the list but it is inconsistent.

 

Thanks!

Josh Boutwell 0 votes
Comment actions Permalink
0
Avatar

Make sure to change the picklist sort order to "Manual Order" and then you can update the "Order" field on each picklist value

Eyal Post 0 votes
Comment actions Permalink
0
Avatar

Hi Eyal,

 

I am still having issues specifying the order.  I have submitted the following:

 

{"url" : "/data/objects/C_Projectpicklisttest", "method": "PUT", "body": {"order": 1, "id": "/C_ProjectSeniors/1", "description": "Testing"}},
{"url" : "/data/objects/C_Projectpicklisttest", "method": "PUT", "body": {"order": 2, "id": "/C_ProjectSeniors/2"}},
{"url" : "/data/objects/C_Projectpicklisttest", "method": "PUT", "body": {"order": 3, "id": "/C_ProjectSeniors/3"}},
{"url" : "/data/objects/C_Projectpicklisttest", "method": "PUT", "body": {"order": 4, "id": "/C_ProjectSeniors/4"}},
{"url" : "/data/objects/C_Projectpicklisttest", "method": "PUT", "body": {"order": 5, "id": "/C_ProjectSeniors/5"}},
{"url" : "/data/objects/C_Projectpicklisttest", "method": "PUT", "body": {"order": 6, "id": "/C_ProjectSeniors/6"}},

There are no errors but I have also tried with the order in double quotes.

 

The results are that the order field is ignored.  Instead the are ordered as :

5, 4, 3, 2, 1, 6  In addition the description field on #1 is ignored.

Any ideas?

Josh Boutwell 0 votes
Comment actions Permalink
0
Avatar

Ok, I finally found the solutions.

 

I have to use a PUT to create a picklist item however the PUT won't accept any other values except the id.

Using POST I can actually update the order variable but I can't create a new entry.

 

So I have to break this into two commands.  One to create and one to update.

 

 

Josh Boutwell 0 votes
Comment actions Permalink