Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

hvrdhn88
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.

hvrdhn88
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);