Script on Email Quick Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2016 12:10 PM
Hi All,
Can we write a script on Email Quick Messages? Like if we select on of the Quick Message and then auto set the Reply To or the CC field.
Please help.
Thanks,
Kannan
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2016 03:18 PM
I do not know of a way to set the To/CC/etc. fields from a Quick Message, however you can set all of these through Client Templates. This is where we apply the logic to set all the custom addresses.
You could also do something like that with a UI Script, but that would be much more advanced.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2016 09:47 PM
You cant script on Quick Message, personally its not preferred to use as you wont be having much control in whats happening - the more you script the more control you will have.
Try to script in Email Actions and Email Scripts like this -
While you are queueing the event, follow this -
1. parm1 should have To list of the recipients.
2. parm2 contains JSON structure of following format
{
addressedTo : "John",
sendCcList:''abc@123.com",
sendBccList: "123@abc.com"',
}
In the email action, check only Event parm 1 cotains recipients check box, uncheck Event parm 2 as recipients check box.
Go to the email scripts tables-
Write a new email script: notification_email_script //you can put any name and its advisable to separate the words with underscore
var jp = new JSONParser();
event.info = jp.parse(event.parm2);
event.addressedTo = event.info.addressedTo;
for (var i=0;i < event.info.sendCcList.length; i++)
email.addAddress("cc",event.info.sendCcList[i]);
for (var i=0;i < event.info.sendBccList.length; i++)
email.addAddress("bcc",event.info.sendBccList[i]);
Go back to the email action -
In the message HTML put the below line at the top-
${mail_script:notification_email_script}
FYI, refer this link for email scripting - Scripting for Email Notifications - ServiceNow Wiki
Happy scripting
Mark if it is helpful or correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 10:28 AM
The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: Scripting for Email Notifications
Visit http://docs.servicenow.com for the latest product documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2016 05:55 AM
Thank you Trevor and Srikanth for your replies.