- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-01-2022 01:55 AM
Hi everyone hope you doing well,
I have a requirement -
send a notification to assigned_to(user select in assigned to),
Email(notification) should include all incident (with same assigned_to & state= in progress),
& these incident should be in an excel sheet format.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-04-2022 12:27 AM
Hi,
you will have to store file to that incident record and include that in email
So just before triggering the email write script to generate excel. I would suggest to use CSV as it's easy
then trigger the email using gs.eventQueue()
Generate CSV file through script
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
ā09-01-2022 02:02 AM
Check this out
https://community.servicenow.com/community?id=community_question&sys_id=585851e71bc18d54ccc253da234bcbef
Please mark my response as correct if it helped you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-03-2022 10:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-01-2022 04:13 AM
Hello Prashant,
To implement your requirement you will need to write after BR on sys_email and use the script shown below:
This will generate and attach the CSV file and may be you can check for .XLS file if you want.
(function executeRule(current, previous /*null when async*/ ) {
var fileData = [];
fileData.push("Number,Caller,Short Desc,Assignment Group,Assigned To");
var tableFieldName = ["number", "caller_id", "short_description", "assignment_group", "assigned_to"];
var assignedTo = "";
//CHECK IF THERE IS ANY OTHER WAY TO GET THE ASSIGNED TO USER
//IF NOT THEN USE THE BELOW APPROACH
var gr = new GlideRecord("incident");
if (gr.get(current.getValue("instance")))
assignedTo = gr.getValue("assigned_to");
//GET ALL THE INCIDENT IF ASSIGNED TO IS NOT EMPTY
if (assignedTo) {
var incRecord = new GlideRecord("incident");
incRecord.addEncodedQuery("assigned_to=" + assignedTo + "^state=2");
incRecord.query();
while (incRecord.next()) {
var fieldsData = [];
for (var fields in tableFieldName) {
fieldsData.push(incRecord.getDisplayValue(tableFieldName[fields]));
}
fileData.push(fieldsData.join(","));
}
//ATTACH THE FILE TO EMAIL
var attachment = new Attachment();
var attachmentRec = attachment.write("sys_email", current.getUniqueValue(), "Incident in your queue.csv", "CSV", fileData.join("\n"));
}
})(current, previous);
Please mark my respsone as helpful/correct, if it answer your question.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-02-2022 12:01 AM
Hello Prashant,
Just wanted to check with you, if the my above response answered your question. If yes, then please do close this thread/question by marking the appropriate response as correct.
If you still need any further help or guidance on this then please update those on this question.
Thanks