- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 04:53 AM
I want to see only 10 records in Related List (Incidents by same caller) in incident form.
current.addQuery('caller_id', parent.caller_id);
var gr = new GlideRecord('incident');
gr.addQuery('active', 'true');
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();
var sysIDs = "";
while (gr.next()){
sysIDs += ", " + gr.sys_id;
}
current.addQuery("sys_id", "IN", sysIDs);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:08 AM
I would recommend this approach:
(function refineQuery(current, parent) {
var incArr = [];
var gr = new GlideRecord('incident');
gr.addQuery('active', 'true');
gr.addQuery('caller_id', parent.caller_id);
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();
while (gr.next()) {
incArr.push(gr.sys_id.toString());
}
current.addQuery("sys_id", "IN", incArr.join(','));
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:08 AM
I would recommend this approach:
(function refineQuery(current, parent) {
var incArr = [];
var gr = new GlideRecord('incident');
gr.addQuery('active', 'true');
gr.addQuery('caller_id', parent.caller_id);
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();
while (gr.next()) {
incArr.push(gr.sys_id.toString());
}
current.addQuery("sys_id", "IN", incArr.join(','));
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:26 AM
Thank you, that was useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:29 AM
You are welcome!