REST API Endpoint to sort Select Fields

Daniel Alonso April 29, 2021

Hi,

I have an integration with Celigo and it basically syncs some values between SalesForce and Jira in a List Custom field. This Custom field is getting feed incrementally.

I need to sort the values Alphabetically once the sync process ends. I was looking for an Endpoint with the REST API to do that, I tried to get it directly with a GET call using:

/rest/api/3/field/customfield_10035/context/18790/sort

But it doesn't exist

And using the URL directly:

/rest/api/3/field/customfield_10035/context/18790/sort.jspa?fieldConfigId=10138&&atl_token=<SOME_TOKEN>

Gave me a Security Token Error.

Any ideas?

1 answer

0 votes
Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 29, 2021

Dear @Daniel Alonso ,

unfortunately, the cloud rest api has no sort endpoint. 

Instead you have to do this on your own. When you read the values from JSON response, you can push them in an array. There are a lot of sort function (depending on the language of your code) that then support array sorting.

See examples for PHP. Python and Java.

So long

Thomas

Daniel Alonso April 30, 2021

Thanks @Thomas Deiler ,

Actually the account are sent sort to Jira, the problem is like for example:

Day 1, I have Account: B, E, C, A. In the Celigo code I sort them and it's ABCE, and they are pushed to Jira in that way, then

Day 2, There are accounts A1, Bell, Cold, Ex and they are pushed to Jira sort A1, Bell, Cold, Ex, but in Jira, the sort is now like:

A-B-C-E-A1-Bell-Cold-Ex

So, I need the sort on Jira level

Daniel

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 30, 2021

Seems they got just appended. Jira works internal with digit object ids (server). When adding new object the id is just increased, so the output is not sorted but just returned from lower to higher ids.

To sort it on Day 2 you need to read + remove existing objects from Jira, add new, sort them and push again to Jira.

So long

Thomas

Daniel Alonso May 3, 2021

That's a lot of resources on the server, I think it's easiest to set a reminder on my calendar and go click on Sort every other day, meanwhile @Atlass

Releases and end point for that.

Thanks any way! Really appreciate the time you took to reply.

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2021

Dear @Daniel Alonso ,

don't forget to press the "green accept answer" button to indicate other readers the successful answering of your question.

So long
Thomas

Daniel Alonso May 10, 2021

Thanks Thomas, but it was not successful answered. I will wait for Atlassian to implement this, if you can vote for the improvement on this request: https://jira.atlassian.com/browse/JRACLOUD-76547

Regards!

Daniel

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2021

Dear @Daniel Alonso ,

which answer would you have accepted as successful?

So long

Thomas

Daniel Alonso May 11, 2021

Thomas,

I would like something that in theory looks really simple as trigger an action thru the API, It's nothing against your approach, it's just that it requires a lot of effort and it doesn't fit the requirement that I'm looking for because I also need the option Ids to perform another automations and deleting and recreating is not suitable.

I don't accept the answer to don't confuse other people that it's looking for this and see it as RESOLVED, which is not the case.

Talking in Jira Terms, it would fit more in WAITING FOR IMPROVEMENT status, don't you think?

Thanks for you understanding and the effort you put on the alternative solution.

Daniel

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2021

Dear @Daniel Alonso ,

I understand your points. Please also understand, that this site is driven by the community (majority of contributors) that have no influence on project development strategies of Atlassian. When the outcome of a discussion is that a suggestion has been created, the answer is best done. One cannot improve this questions with other answers. The REST endpoint simply does not exist.

Its better to indicate other readers, there is a solution found and they can find more information in the thread. Finally they will follow the link to the suggestion and probably vote. When the answer is not accepted, the chance that it is read, is lower.

Btw. It says "Accept answer" and not "Problem solved".

So long

Thomas

Suggest an answer

Log in or Sign up to answer