- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 07:31 AM
I am very new to the Service Now administration.
im trying to send an email to one of my vendors when certain values are selected on my record producer form.
then i want to take other values from my record producer and send it in a formatted email to the vendor. without them getting all the information. i would say 90% of my variables in my record producer go into the description field in the resulting ticket, but the vendor I have doesn't need all of that, which is what is making this endeavor harder for me.
is anyone able to help me get started on how to do this, ive seen a few questions like this on the forums, but they are way ahead of where i am at. I pick up on these things quickly, so any guidance getting started would be highly appreciated.
Solved! Go to Solution.
- Labels:
-
Notifications
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 03:40 PM
I was able to get this to work with help from this post: https://community.servicenow.com/community?id=community_question&sys_id=fcff3be9db66fbc02be0a851ca961904
Sample of the code that worked for me:
In Record Producer:
var EmailData = {"Date" : DateField, "Position" : PositionInfoField, "ReportedBy" : ReportedByField, "Description" : DescriptionField, "Subj1" : Subject1Field, "Subj2" : Subject2Field};
var parser = new JSON();
var notificationContent = parser.encode(EmailData);
gs.log('JSON object:' + notificationContent);
gs.eventQueue('EmailEvent',current , notificationContent , '');
in Email Script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var jsonObject=event.parm1;
// Parsing JSON object:
var obj = JSON.parse(jsonObject);
template.print(obj.Date+"<br>");
template.print(obj.Position+"<br>");
template.print(obj.ReportedBy+"<br>");
template.print(obj.Description+"<br>");
// Set Subject in resulting email
email.subject =obj.Subj1+" - "+ obj.Subj2;
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 10:40 AM
ok i made that change, and now its not showing anything, no error nothing. ive even gone to just use your code straight, without any modification except this
var data1 = "Jeff"
var data2 = "Siegel"
within the record producer.
i assume after adjusting the record producer, i need to create a new record, so that it kicks off the event.
i cant imagine to know what im doing wrong here...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 10:47 AM
You are correct. For every change that you do in the record producer Script field, you need to submit a new record to see that changes.
To test the notification , you need to submit the record producer each time.
Could you paste your record producer code and the email script code here pls...
Or Contact me and we can have a look at the script up close +91-9900177730(Whatsapp)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 10:57 AM
here is everything
Record Producer:
var data1 = "jeff";
var data2 = "Siegel";
var notificationContent = {};
notificationContent.detail1 = data1;
notificationContent.detail2 = data2;
gs.eventQueue(current, 'VendorEmail' , notificationContent , '');
Email Script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var magicData = event.Parm1;
var magicDataJSON = JSON.parse(magicData);
var detail1 = magicDataJSON.detail1;
var detail2 = magicDataJSON.detail2;
template.print(detail1);
template.print(detail2);
})(current, template, email, email_action, event);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 11:08 AM
In your Notification, the Table field is empty. Just set the table to whichever table your Record Producer is on. And The Event Record has a Table field too... Set it to the same table name as the notification's.
Also, have you selected your event in the Event name field just under the Send When in the notification?
And rather than using the Preview notification, check the email logs. It's painful, but surefire way to find if things are working or not.
To navigate to email logs,
System Logs -> Emails
Sort the records by Created Z-A to check the latest email which may have triggered. And then
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 11:13 AM
Yeah during troubleshooting i had those tables filled out, but then noticed in your screenshots they were empty so i removed them. ive re-added, and yes, i have the event in the event box, sorry it got cut off. ive created a new record. and nothing is showing up in my email logs except the incident created email, which is not part of this exercise.