- 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 06:32 PM
template.print("Opened_by"+current.opened_by);
template.print("sys_created_by"+current.sys_created_by);
template.print("Opened_by_name"+current.opened_by.name);
template.print("Opened_by"+current.sys_created_by.name);
add these above four lines of code before email.setFrom();
And submit a record producer then see the email and let me know the Output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 06:47 AM
This is what I used and still getting the same msg as earlier
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
template.print("Opened_by"+current.opened_by);
template.print("sys_created_by"+current.sys_created_by);
template.print("Opened_by_name"+current.opened_by.name);
template.print("Opened_by"+current.sys_created_by.name);
email.setFrom(current.sys_created_by.name +" <"+current.sys_created_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);
Date: Tue, 10 Jul 2018 06:45:44 -0700 (PDT)
From: "undefined <undefined>" <mydev@service-now.com>
Reply-To: myDEV ServiceNow <mydev@service-now.com>
To: itil-sn-test@***
Message-ID: <2700178.57149.1531230344310@app128148.sjc4.service-now.com>
Subject:
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-ServiceNow-Source: Notification-03b53f031307df40be045d622244b050
X-ServiceNow-SysEmail-Version: 2
Precedence: bulk
Auto-Submitted: auto-generated
X-ServiceNow-Generated: true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 04:07 PM
upload the email preview
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2018 06:51 AM
its working , I am not using the variable name from the tables , i was using the variable name from the record producer. , thanks for the time 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2019 05:34 AM
It is not attaching anything in the email. Just sending a downloadable link. If the person receiving it doesn't have a login, then they cannot access it.