- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 04:07 PM
Hi ServiceNow Gurus!
I am creating a business rule that needs to show the first record created in 'sys_user_grmember' sorted by 'sys_created_on'. Part of the code in my
business rule is:
var grug = new GlideRecord('sys_user_grmember');
grug.addQuery('user', current.user);
grug.addQuery('group.active', true);
grug.addQuery('group.type', 'CONTAINS', itil);
grug.orderByDesc('sys_created_on');
grug.setLimit(1);
grug.query();
I think that what's wrong with the code is the line "grug.orderByDesc('sys_created_on');"
Please help!
Thank you!
Carlo
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 04:26 PM
Hello Carlo,
Replace line grug.orderByDesc('sys_created_on'); with grug.orderBy('sys_created_on');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 04:21 PM
can we try itil in quotes in below code?
grug.addQuery('group.type', 'CONTAINS', 'itil');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 04:26 PM
Hello Carlo,
Replace line grug.orderByDesc('sys_created_on'); with grug.orderBy('sys_created_on');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2025 11:16 AM
Can this be done in the report designer without scripting?
I'd like a dashboard visualization to show the oldest requested item number with the date next to it. There's no way in filters I can figure out how to show the "Oldest" only. I have a group set to only show 1 maximum row.
Is there a filter I can enable to just show the oldest row? Grouping creates a hiearachy and I don't want this. I want something similar to a TOP[1} by Date function.