Find all incidents handled by a user

nj5
Kilo Contributor

Hello community,

May i ask you how to extract all tickets handled by a user, because when i do a research with Keywords of the user's name, it shows me only tickets with a comment inserted, but a user :

- can add an attachment, without a comment

- reassign the ticket without adding comment.

So, the result of search doesn't reflect reality.

When a user insert a comment, add an attachment, or simply reassign it without comment, the name appears in the Activity. Why it is ignored on query ?

 

Thank you in advance.

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Ankit P
Mega Guru

Well there are 2 solutions to this:

1. If you only need a list of incidents handled by a user, just run the below in background script. You can replace "admin" by user id of your choice.

var audit = new GlideRecord('sys_audit');
audit.addQuery('user', 'admin');
audit.query();

while(audit.next()){

var gr = new GlideRecord('incident');
gr.addQuery('sys_id', audit.documentkey);
gr.query();
if(gr.next()){
gs.print(gr.number + " - " + gr.short_description);
}
}

 

2. Create a Database View connecting sys_audit and incident tables at Document Key = Sys ID and you can filter the user using user ID. Below is the screen shot.

find_real_file.png

And the result:

find_real_file.png

View solution in original post

3 REPLIES 3

ServiceNowSteve
Giga Guru

I would run a report on the sys_audit table. It should give you all of the information of what that tech touched.

Ankit P
Mega Guru

Well there are 2 solutions to this:

1. If you only need a list of incidents handled by a user, just run the below in background script. You can replace "admin" by user id of your choice.

var audit = new GlideRecord('sys_audit');
audit.addQuery('user', 'admin');
audit.query();

while(audit.next()){

var gr = new GlideRecord('incident');
gr.addQuery('sys_id', audit.documentkey);
gr.query();
if(gr.next()){
gs.print(gr.number + " - " + gr.short_description);
}
}

 

2. Create a Database View connecting sys_audit and incident tables at Document Key = Sys ID and you can filter the user using user ID. Below is the screen shot.

find_real_file.png

And the result:

find_real_file.png

nj5
Kilo Contributor

Thank you sirs.

 

Have a nice day.