- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 08:27 PM
I want to send email for only 20% of incidents with close/resolved how can i achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 10:32 PM - edited ‎10-18-2023 10:34 PM
Hi @RMU
Thanks for confirmation...!!
Not sure if this business requirement....but assuming you are writing scheduled job to send the email.
Following script might help...!!
/*1. Glide Record on incident table & get row count */
var grInc = new GlideRecord("incident");
grInc.addEncodedQuery('stateIN6,7');
grInc.query();
/*2. Here we will get the totla number of incident */
var totalInc = grInc.getRowCount();
gs.print("Total incident count = " + totalInc);
/*3. Calulate 20% of totalInc */
var percentage = 20;
var number = (percentage/100) * totalInc;
gs.print("20% of totalInc = " + number);
/*4. Need to Glide record on Incident table again to limit the recors with "20% of totalInc" */
var gr = new GlideRecord("incident");
gr.addEncodedQuery('stateIN6,7');
gr.setLimit(number);
gr.query();
while(gr.next()){
gs.print(gr.number);
// gs.eventQueue('ebent_name',gr,gr.caller);
}
This logic will get the 20% random incident from total incident
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 08:37 PM
Hi @RMU ,
You can just use addEncodedQuery() in ur glide record & copy paste the query into it. Go to ur list view select those 20% incidents manually by applying filter , run that filter copy the query from the filter by right clicking on it & paste it in ur encoded query.
In that GlideRecord u can call event & trigger the notification.
Ur notification trigger point should be when event fired.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 10:00 PM
Hi @RMU
20% in the sense , if there are 100 incidents with closed/resolved then send email to only 20 ??
Is my understanding is correct...??
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 10:12 PM
Yeah , exactly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 10:32 PM - edited ‎10-18-2023 10:34 PM
Hi @RMU
Thanks for confirmation...!!
Not sure if this business requirement....but assuming you are writing scheduled job to send the email.
Following script might help...!!
/*1. Glide Record on incident table & get row count */
var grInc = new GlideRecord("incident");
grInc.addEncodedQuery('stateIN6,7');
grInc.query();
/*2. Here we will get the totla number of incident */
var totalInc = grInc.getRowCount();
gs.print("Total incident count = " + totalInc);
/*3. Calulate 20% of totalInc */
var percentage = 20;
var number = (percentage/100) * totalInc;
gs.print("20% of totalInc = " + number);
/*4. Need to Glide record on Incident table again to limit the recors with "20% of totalInc" */
var gr = new GlideRecord("incident");
gr.addEncodedQuery('stateIN6,7');
gr.setLimit(number);
gr.query();
while(gr.next()){
gs.print(gr.number);
// gs.eventQueue('ebent_name',gr,gr.caller);
}
This logic will get the 20% random incident from total incident
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates