Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

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

Sanjeev Kumar1
Kilo Sage

Hi,

 

Go to --> Module 

Create a new module "Assigned to me" under Incident Application.

Using following condition

javascript:getMyAssignments()

 

find_real_file.png

Thanks sk, But how can i achieve that by using script

Hi,

you need to use GlideAggregateAPI.

For more detail see it.

 

https://docs.servicenow.com/bundle/london-application-development/page/app-store/dev_portal/API_reference/GlideAggregate/concept/c_GlideAggregateAPI.html#r_GlideAggregate-getAggregate_String_String

Devyani_6
Mega Guru

Hi Ankit,

Try below script in Background scripts to get total incidents assigned to currently logged in user.

var gr = new GlideRecord("incident");
gr.addQuery("assigned_to",gs.getUserID());
gr.query();

var count = gr.getRowCount();
gs.print(count);

Regards,
Devyani