How to check total ticket assigned to a user using script?

Ankit49
Kilo Contributor

How to check total ticket(incident) assigned to currently login user by using script?

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

here we go.

 

sample script , just to check incident.

you can check any other table as well. make the modification based on your need.

 

var count=0;
var gr = new GlideRecord('incident');
gr.addEncodedQuery('stateNOT IN6,7,8');
gr.addQuery('assigned_to',gs.getUserID());
gr.query();
while(gr.next())
{
count++;
gs.print(gr.number);
}
gs.print(count);

 

View solution in original post

6 REPLIES 6

Hi,

the above code will give count of all incidents assigned to the logged in user (Active+inactive incidents).

Add gr.addActiveQuery(); to get only active incidents.

Thanks.

Harsh Vardhan
Giga Patron

here we go.

 

sample script , just to check incident.

you can check any other table as well. make the modification based on your need.

 

var count=0;
var gr = new GlideRecord('incident');
gr.addEncodedQuery('stateNOT IN6,7,8');
gr.addQuery('assigned_to',gs.getUserID());
gr.query();
while(gr.next())
{
count++;
gs.print(gr.number);
}
gs.print(count);