- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2017 12:30 PM
Is it possible to dotwalk in an Addquery filter conditon?
Here is what I am trying to do.
I am attempting to get the top 5 most frequently requested items by the current user. I was able to get this to work by using the opened by field on the RITM but I would like to dotwalk to the parent and get only RITM where the parent Req's field 'Requested_for' is the current user. Heres what I have so far.
data.frequentItems = [];
var currentUser = gs.getUserID();
var count = new GlideAggregate('sc_req_item');
count.addQuery('opened_by', gs.getUserID()); // THIS IS WHERE I NEED TO GET request.requested_for
count.addAggregate('COUNT', 'cat_item');
count.orderByAggregate('count', 'cat_item');
count.chooseWindow(1, 5);
count.query();
while (count.next()) {
var itemRecord= count.cat_item.getRefRecord();
var itemCount= count.getAggregate('COUNT', 'cat_item');
var item = {
sys_id: itemRecord.sys_id.getDisplayValue(),
picture: itemRecord.picture.getDisplayValue(),
name: itemRecord.name.getDisplayValue()
}
data.frequentItems.push(item);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2017 12:39 PM
Hello Corey,
Yes you can dot-walking at addQuery level i.e count.addQuery('request.requested_for', gs.getUserID()); Below is the sample code I tried on my instance.
var currentUser = gs.getUserID();
var count = new GlideAggregate('sc_req_item');
count.addQuery('request.requested_for', gs.getUserID()); // THIS IS WHERE I NEED TO GET request.requested_for
//count.addAggregate('COUNT', 'cat_item');
//count.orderByAggregate('count', 'cat_item');
//count.chooseWindow(1, 5);
count.query();
while (count.next()) {
gs.addInfoMessage(count.request.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2017 12:39 PM
Hello Corey,
Yes you can dot-walking at addQuery level i.e count.addQuery('request.requested_for', gs.getUserID()); Below is the sample code I tried on my instance.
var currentUser = gs.getUserID();
var count = new GlideAggregate('sc_req_item');
count.addQuery('request.requested_for', gs.getUserID()); // THIS IS WHERE I NEED TO GET request.requested_for
//count.addAggregate('COUNT', 'cat_item');
//count.orderByAggregate('count', 'cat_item');
//count.chooseWindow(1, 5);
count.query();
while (count.next()) {
gs.addInfoMessage(count.request.number);
}
