How to print incident record created on last10 days with out using encoded query?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 10:14 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 10:29 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2024 12:16 AM
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