API call to sort a custom field | Community
Skip to main content
New Participant
October 21, 2022
Solved

API call to sort a custom field

  • October 21, 2022
  • 1 reply
  • 1359 views

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"&parameterID=5a0a7b3401815c9b9cd8ed5b0aa7d276&label="ABC" 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

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by William--

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!

1 reply

William--
William--Accepted solution
New Participant
October 21, 2022

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!

If you like my content, please take a moment to view and vote on my Idea Requests: https://tinyurl.com/4rbpr7hf
MollieShAuthor
New Participant
October 24, 2022

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