How can i get all the incident Number where assigned_to user is same?

Ankit Kumar6
Tera Contributor

Hello,

 How can i get all the incident Number where assigned to user is same.

 

Thanks,

1 ACCEPTED SOLUTION

Manmohan K
Tera Sage

Hi @Ankit Kumar6 

 

You can use below code to get Incident numbers for a particular assigned to user

 

var assignedToUser = ''; // Replace with the sys_id of the assigned to user

var incidentNumbers = [];

var gr = new GlideRecord('incident');
gr.addQuery('assigned_to', assignedToUser);
gr.query();

while (gr.next()) {
    incidentNumbers.push(gr.number.toString());
}

gs.info("Incident numbers assigned to " + assignee + ": " + incidentNumbers.join(', '));

 

View solution in original post

3 REPLIES 3

mattystern
Kilo Sage

Hi @Ankit Kumar6 

 

You can use "is same" to compare two fields referencing the same value. EX:

mattystern_3-1692902585917.png

 

You can use "Is (dynamic) Me" if you are looking for assigned to being the same as the logged in user.

mattystern_2-1692902531210.png

 

Filters are being applied on Incidents > All in these screenshots.

 

Further reading here on creating a filter on a list. Hopefully this helps!

 

-Matt

Manmohan K
Tera Sage

Hi @Ankit Kumar6 

 

You can use below code to get Incident numbers for a particular assigned to user

 

var assignedToUser = ''; // Replace with the sys_id of the assigned to user

var incidentNumbers = [];

var gr = new GlideRecord('incident');
gr.addQuery('assigned_to', assignedToUser);
gr.query();

while (gr.next()) {
    incidentNumbers.push(gr.number.toString());
}

gs.info("Incident numbers assigned to " + assignee + ": " + incidentNumbers.join(', '));

 

Appli
Mega Sage
Mega Sage

Hi, and without any coding:

- go to incident list view

- group by "Assigned to" field:

 

Appli_0-1692944386609.png

 

Hope it helps