- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 04:59 AM
Hello All,
I have used below encoded query and I want to add order by on opened_at field which is a date field.
At present it is showing old to new records however I want to showcase new to old records.
Below is my encoded query copied from incident table
caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^opened_atONLast6months@javascript:gs.beginningOfLast6Months()@javascript:gs.endOfLast6Months()^EQ
Thank you in advance.
Regards,
Priyanka Shinde
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 12:57 AM
Hi Priyanka
ORDERBYDESC = New to Old
caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^opened_atONLast6months@javascript:gs.beginningOfLast6Months()@javascript:gs.endOfLast6Months()^EQ^ORDERBYDESCopened_at
Shakeel Shaik 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 05:07 AM
Hi
please see page https://docs.servicenow.com/bundle/sandiego-platform-user-interface/page/use/using-lists/concept/c_E...
You will find there the explanation for adding the sort order to an encoded query string.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 07:03 AM
Hello Maik,
Thank you for your reply.
Will you be able to help me add the mentioned sorting condition available in the doc to my existing encoded query. I want to sort on opened date.
caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^opened_atONLast6months@javascript:gs.beginningOfLast6Months()@javascript:gs.endOfLast6Months()^EQ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 07:16 AM
caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^opened_atONLast6months@javascript:gs.beginningOfLast6Months()@javascript:gs.endOfLast6Months()^EQ^ORDERBYopened_at
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 05:09 AM
Hi Priyanka
you can use orderBy/orderByDesc.
grIncident.orderByDesc('opened_at'); - for descending order and
grIncident.orderBy('opened_at'); - for ascending order.
sample:
var grIncident = new GlideRecord('incident');
grIncident.addEncodedQuery("active=true");
grIncident.orderByDesc('opened_at');//descending order.
grIncident.query();
while (grIncident.next()) {
//
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP