- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2019 11:56 PM
Hi Folks,
I want to show only 20 records that are opened for the user.
function refineQuery(current, parent) {
var qc = current.addQuery("opened_for", parent.opened_for);
current.addQuery("sys_id", "!=", parent.getUniqueValue());
current.orderByDesc("sys_created_on");
})(current, parent);
Regards,
Vijay
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2019 12:08 AM
try to do glide record and then use current object .
sample code:
var inc = new GlideRecord('incident');
inc.addQuery('caller_id', parent.caller_id);
inc.orderByDesc('sys_created_on');
inc.setLimit(10);
inc.query();
var ids = [];
while (inc.next()) {
ids.push('' + inc.sys_id);
}
current.addQuery('sys_id', ids);
just modify this script based on your need. give a try.
Kindly refer the below thread for another sample code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2019 11:58 PM
Hi Vijay,
Go through below link will help you,
If my reply helps you at all, I’d really appreciate it if you click the Helpful button and if my reply is the answer you were looking for, it would be awesome if you could click both the Helpful and Accepted Solution buttons!
Regards,
Pratiksha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2019 11:59 PM
Hi
Can you try this way -
var count = 20;
current.addQuery("opened_for", parent.opened_for);
current.addQuery("sys_id", "!=", parent.getUniqueValue());
current.orderByDesc("sys_created_on");
current.setLimit(count);
Regards,
Omkar Mone

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2019 12:08 AM
Hi
Can you try with removing all and just keeping -
current.setLimit(20);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2019 12:01 AM
use setLimit()
Updated Code:
function refineQuery(current, parent) {
var qc = current.addQuery("opened_for", parent.opened_for);
current.addQuery("sys_id", "!=", parent.getUniqueValue());
current.orderByDesc("sys_created_on");
current.setLimit(20);
})(current, parent);