- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2017 01:38 AM
I have had to make some modifications to the approvals widget so instead of showing only the unapproved tickets, I'm having to show the closed ones as well.
What I need to implement is, for instance, if I limit the pool to 10 and if a user has 3 unapproved tickets it will show those at the top followed by the 7 most recent approved tickets. I managed to get the list to sort by the date a ticket was opened by adding gr.orderBy('sys_created_on'); but I want to also filter for 'active' tickets so if a user has any unapproved tickets they will display at the top? I was wondering if this is doable and if someone could shed some light?
var gr = new GlideRecord('sysapproval_approver');
- gr.setLimit(10);
- gr.orderBy('sys_created_on');
Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2017 02:05 AM
Oh!
I see.
You can use the
gr.orderByDesc() multiple times and that way set more than one column to sort by
gr.orderByDesc('column_A')
gr.orderByDesc('column_B')
gr.orderByDesc('column_C')
Guessing that solves you problem right ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2017 01:43 AM
- var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('active',true)
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2017 01:57 AM
Thanks Steve, but this will only show the active ones? I want to show both and if a user has any active ones they will show first followed by the approved ones.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2017 02:05 AM
Oh!
I see.
You can use the
gr.orderByDesc() multiple times and that way set more than one column to sort by
gr.orderByDesc('column_A')
gr.orderByDesc('column_B')
gr.orderByDesc('column_C')
Guessing that solves you problem right ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2017 02:07 AM
Otherwise you will have to sort through them in code and then present them "out of order" from the data set.
Perhaps create a Ditionary with al the glideRecords in and usse that to present the data.
Think that is going to be messy.