Adding a CC to an email notification that will pull from a field in Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2016 09:02 AM
Hi All,
I would like to add a CC to an email notification, however I need the CC name to come from a field in the request item. Is this possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2016 11:48 AM
You can construct a JSON in the variable and pass it in the eventQueue call
gs.eventQueue('eventname',current,parm1,parm2)
In the JSON of parm1, one variable can be the CCList email
In the mail script you have to write - if event.parm1 is a JSON string then you can access in the email script like below
var jp = new JSONParser();
event.info = jp.parse(event.parm1);
I have given an example of a way that we follow to pass multiple information in parameters and this can give much more idea for you -
While you are queueing the event, follow this - gs.eventQueue('event', current, parm1, parm2);
1. parm1 contains JSON structure of following format
{
addressedTo : "John",
sendCcList:''abc@123.com",
sendBccList: "123@abc.com"',
}
2. parm2 should have To list of the recipients.
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.parm1);
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}
Mark if it is helpful or correct, feedback is appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2016 11:55 AM
how is the name stored in the field.. is it a reference field to the sys user table an email address or what??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2016 12:23 PM
Hi Raymond,
Yes it is a reference field that references the sys user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2016 01:18 PM
ok that is pretty simple... assuming the notification is on the requested item table.. you should be able to either grab the sid for the user and query the user table to get the object.. or dot walk to the user.email field inside the notification.. then just add the email to the cc line with a
email.addAddress("cc",splitThis[i]);
command inside of a mail script.. in this case splitThis is an array containing the email addresses for people i want to add.. and i am adding em as i loop through the array.