Hi all, I have figured out how to add a parameter to a custom field via a API call, but now I would like to sort the field to be in alphabetical order. This is what I have for the adding of a new value:
https://mydomain.sb01.workfront.com/attask/api/v15.0/POPT?value="ABC"¶meterID=5a0a7b3401815c9b9c... with a POST command.
Do I need a PUT command to sort the whole parameter or is it to the parameter group? And if you use displayOrder, what is the value? displayOrder=??? it needs to be a integer.
Any assistance would be greatly appreciated. Thanks, Mollie
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Mollie,
1. Parameter Group refers to Custom Form Sections, so that's unrelated to your current challenge.
2. Display Order refers to the order in which the Parameter Options are listed. 1 is first, 2 is second, etc.
To my knowledge there is no API endpoint or syntax that will alphabetize the Parameter Options for you. In the UI, checking that box while editing a dropdown field reorders the list using JavaScript, not an API call. The API call that is sent to Workfront when saving the custom form informs Workfront that it should set a new order for the Parameter Options of the dropdown field, but it's not a simple "alphabetize this list" command - it says "set the display order of Alpha to 1. set the display order of Beta to 2. set the display order of Charlie to 3." and so on.
To do this action via API, your script or scenario that is sending the API command to Workfront should POST the new Parameter Options, then GET them all from the Parameter, then use its own logic to alphabetize the list, then set the new display order values accordingly, then PUT those updates with the new display order back to Workfront .
Honestly it's probably not worth the amount of effort needed to code the function, unless you need to do this to hundreds of fields.
If anyone knows a secret unpublished endpoint that performs this action, I'm interested to know it!
Views
Replies
Total Likes
Hi Mollie,
1. Parameter Group refers to Custom Form Sections, so that's unrelated to your current challenge.
2. Display Order refers to the order in which the Parameter Options are listed. 1 is first, 2 is second, etc.
To my knowledge there is no API endpoint or syntax that will alphabetize the Parameter Options for you. In the UI, checking that box while editing a dropdown field reorders the list using JavaScript, not an API call. The API call that is sent to Workfront when saving the custom form informs Workfront that it should set a new order for the Parameter Options of the dropdown field, but it's not a simple "alphabetize this list" command - it says "set the display order of Alpha to 1. set the display order of Beta to 2. set the display order of Charlie to 3." and so on.
To do this action via API, your script or scenario that is sending the API command to Workfront should POST the new Parameter Options, then GET them all from the Parameter, then use its own logic to alphabetize the list, then set the new display order values accordingly, then PUT those updates with the new display order back to Workfront .
Honestly it's probably not worth the amount of effort needed to code the function, unless you need to do this to hundreds of fields.
If anyone knows a secret unpublished endpoint that performs this action, I'm interested to know it!
Views
Replies
Total Likes
Thanks, kinda disappointing but thank you for confirming. I may have to do the complicated sort since it is a list that is changing about every other week. Thanks, Mollie
Views
Replies
Total Likes
Hi,
So I've gotten as far as getting the new list, sorting it and updating the display order. The problem is I can't figure out the PUT command to replace the display order. Any help would be appreciated, we add a new item to this list about once a week, so it would be really nice to have it sorted.
And actually I've noticed that when posting new names to the list if I don't do the manual sort in Workfront the api call POSTs the new values in alpha order, but only the new ones. Thanks, Mollie
Views
Replies
Total Likes