- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2018 09:48 AM
I have a requirement where we created a table XYZ and a record producer , when the record producer is submitted the record will be inserted in the the table XYZ , when ever a new record is inserted, we need to send a notification to a group ,
if user is John who submitted the record producer , we need to get john's email address and send message from that, not from default ServiceNow address. and cc the user too
and If a record has an attachment, send the attachment along with the outbound message.
How do we achieve this ?
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2018 09:58 AM
It worked for me. Here is the Code I tested:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
email.setFrom(current.opened_by.name+" <"+current.opened_by.email+">");
printattachments();
function printattachments(){
var gr =new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
gr.query();
while(gr.next()){
template.print('Attachment: <a href="http://'+gs.getProperty("instance_name")+'.service-now.com/sys_attachment.do?sys_id='+ gr.sys_id+'">'+ gr.file_name+'</a>');}
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2018 10:21 AM
Do I need to have opened_by in my record producer ? is there a way to debug it ?
I just added the opened_by to my record producer , but still not working , it is still displaying my company's email
From: "undefined <undefined>" <****dev@service-now.com>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2018 01:44 PM
Check the Created by user is having email ID or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2018 03:24 PM
yes , it has email address
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2018 04:55 PM
Validate below items and let me know:
- when you log in as John and submit the Record Producer then a new record is inserted in XYZ table. Validate the Opened by column for that record. That should be John's User record. and validate tht sys ID should match with John's user record.
- Validate that Notification is written on XYZ table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2018 05:39 PM
I validated it , there is no opened_by but we have sys_created_by and changed the code in the email script with this and checked but still showing undefined