- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2020 09:01 AM
Hi,
someone help on incident script,
send incident details list to assigned to if incident state is OnHold on single notification .
ex: DavidLoo hasbeen assigned to 10-incidents , in 10-incidents there are 7 incidents have state -onhold. so DavidLoo should receive 7-incident details (number, shortdescription, caller , priority) in a single email.
i tried with below script, it is getting single incident details, how to get all in single email.
template.print("number :"+"${number}\n");
template.print("number :"+"${priority}\n");
template.print("number :"+"${caler_id}\n");
template.print("number :"+"${short_description}\n");
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2020 10:00 AM
Hi,
I just updated the job code
It triggered 3 emails to 3 different users
Email triggered to David Loo has incident info Assigned to David Loo
Email triggered to Rosie Mathews has incident info Assigned to Rosie Mathews
Email triggered to Fred Luddy has incident info Assigned to Fred Luddy
Now the only thing you need to check is why it didn't send email to other 6 users
Updated Job Code:
sendEmail();
function sendEmail() {
var gr = new GlideAggregate("incident");
gr.addAggregate("COUNT");
gr.addEncodedQuery('active=true^assigned_toISNOTEMPTY');
gr.groupBy("assigned_to");
gr.query();
while(gr.next()) {
var user = gr.assigned_to;
var incRec = new GlideRecord('incident');
incRec.get('assigned_to', user);
gs.eventQueue('test_list', incRec, incRec.assigned_to, incRec.assigned_to);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 11:21 AM
yes i m getting right email "Test-List" but if we see it is triggering multiple mails for Freedleddy .
if you see below image there are 12 assignedto records are there right,
but is it triggering for 2 -assigned-to users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 02:17 PM
yes i m getting right email "Test-List" but if we see it is triggering multiple mails for Freedleddy .
if you see below image there are 12 assigned-to records are there right,
but it is triggering for 2 -assigned-to users only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 09:07 PM
the current script would trigger for every incident record.
So here you need to use GlideAggregate
Updated job script; it would trigger single email for each assigned_to user
var agg = new GlideAggregate('incident');
agg.addEncodedQuery('active=true^assigned_toISNOTEMPTY');
agg.groupBy('assigned_to');
agg.query();
while(agg.next()){
var incidentSysId = agg.getValue('sys_id');
var gr = new GlideRecord('incident');
gr.get(incidentSysId);
gs.eventQueue('test-list', gr, gs.getUserID(), gs.getUserName());
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2020 11:03 AM
Hi Ankur,
sorry to say this, it is not working.
sendEmail();
function sendEmail() {
var agg = new GlideAggregate('incident');
agg.addEncodedQuery('active=true^assigned_toISNOTEMPTY');
agg.groupBy('assigned_to');
agg.query();
while (agg.next()) {
var incidentSysId = agg.getValue('sys_id');
gs.info("Test-List : "+incidentSysId);
var gr = new GlideRecord('incident');
gr.get(incidentSysId);
gs.eventQueue('test-list', gr, gs.getUserID(), gs.getUserName());
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2020 10:50 PM
Hi,
let me check and inform
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader