Fetch All incident number of given user
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2022 03:26 AM
Hello All,
I want to fetch all incident numbers of the same caller.
For example, suppose the caller is Abel tutor then print all incident numbers related to Abel tuter.
Thank You.
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2022 07:43 AM
@Sagar_pawar Please try the below code
var inc = new GlideAggregate("incident");
inc.groupBy("caller_id");
inc.groupBy("number");
inc.query();
var incObj = {};
while(inc.next()){
var caller = inc.caller_id.getDisplayValue();
if(!caller){
caller = "EMPTY";
}
if(!incObj[caller]){
incObj[caller] = [];
}
incObj[caller].push(inc.number.toString());
}
gs.info(JSON.stringify(incObj));
Result:
Please mark as correct answer if this solves your issue.
Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023
ServiceNow Community Rising Star, Class of 2023