Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 04:45 AM
try this
var x, y;
var req, item;
var i = 1;
var gr2 = GlideRecord('sc_req_item');
gr2.addQuery('requested_for', '86f01750db3cdf00269cfd431d9619d3');
gr2.addQuery('cat_item', 'e660f7838781b1101709a8280cbb35e0');
gr2.orderByDesc('sys_created_on');
gr2.setLimit(2);
gr2.query();
while (gr2.next()) {
if (i == 1) {
x = gr2.sys_id;
i++;
} else if (i == 2) {
y = gr2.sys_id;
i++;
}
gs.info('sys_id=' + gr2.sys_id + ' for=' + gr2.requested_for + ' created=' + gr2.sys_created_on);
}
gs.info('id1=' + x + ' id2=' + y);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader