Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to sort in the specified order by addQuery()

ghc
Tera Contributor

The retrieved data is sorted in the order of the field status 05 02 01

thanks!

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

what do you mean by sorting with field status?

Are these the choice values 5,2, 1

Share your script and share some screenshot

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

That is to say, the retrieved data has three states of 05 01 02. I want to make 05 at the top and 01 and 02 at the bottom. Can addquery be implemented? Is there any other way to implement it

Hi,

are those the choice values of some field?

Anyhow which sorting is this 05 -> 01 -> 02?

It's not even ascending or descending

You can use orderBy() -> for ascending

orderByDesc() -> for descending

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader