How to print incident record created on last10 days with out using encoded query?

Saranya K
Tera Contributor

Hi all,

 

I need to print the incident count create last 10 days for state wise without using encoded query created on last 10 days instead of that we need to use addquery how we can achieve this

2 REPLIES 2

Saurabh _
Tera Guru

In background script you can write code like orderbydesc('sys_creatrd_on', '>', 'javascript: gs.beginningofLastWeek')

setlimit(10)

By modifying these codes you can achieve your requirement.

 

Jyoti Jadhav9
Tera Guru

Hi @Saranya K 

 

Please see the below script without the encodedQuery method and try it:

var gr = new GlideAggregate("incident");
//gr.addQuery("active","true");
gr.addQuery("sys_created_on", ">=", gs.daysAgo(10));
gr.addAggregate('COUNT');
gr.groupBy('state');
gr.query();

while(gr.next())
{
gs.print('Incident State: ' + gr.getDisplayValue('state')+" with count:"+gr.getAggregate('COUNT'));
}

 

Please hit the like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

 

Thanks & Regards

Jyoti Jadhav