RITM Variable Used In Notification (Send To)

kevinthury
Tera Guru

We receive standard forms via email from individuals outside of our domain.   These email are generated by an auto process and are always sent by a generic Service Account that is not a user in our list.   As such the RITM are "Requested For = Guest"   The Inbound Email Action generates a RITM and the associated workflow extracts select comments from the Description and populates variables on the RITM.   Two of these variables are the sender's email address along with another pertinent email address.

Variable Names = 'submitter_email' & 'employee_email'

We are looking to utilize these extracted email addresses in a Notification, but am not having luck getting this to work.     The workflow is configured to create event, which will trigger the notification.  

Event Name = training.other

I'm certain scripting will be involved, but am not well versed yet.   I've found other similar topics for adding variables to Notifications and what I found generally references adding values to a body of the message, which I am able to do.

I am struggling with the email addresses and am hoping I can get some help here.   Thanks in advance.

1 ACCEPTED SOLUTION

mohamadcharafed
ServiceNow Employee
ServiceNow Employee

Hi Kevin



So from what i understand, you generate a notification on the sc_req_item record and you want to CC the emails in the item variables : 'submitter_email' & 'employee_email'



You can create a Mail script which can go and fetch the variables and add them to the CC in your notification. You can use something like below in the mail script :



var item= new GlideRecord('sc_req_item');


item.get(current.sys_id);


email.addAddress("cc", item.variables.submitter_email,item.variables.submitter_email);


email.addAddress("cc", item.variables.employee_email,item.variables.employee_email);



For reference : http://wiki.servicenow.com/index.php?title=Scripting_for_Email_Notifications#Adding_CC_and_BCC_Recip...



Cheers


Mohamad


View solution in original post

5 REPLIES 5

mohamadcharafed
ServiceNow Employee
ServiceNow Employee

Hi Kevin



So from what i understand, you generate a notification on the sc_req_item record and you want to CC the emails in the item variables : 'submitter_email' & 'employee_email'



You can create a Mail script which can go and fetch the variables and add them to the CC in your notification. You can use something like below in the mail script :



var item= new GlideRecord('sc_req_item');


item.get(current.sys_id);


email.addAddress("cc", item.variables.submitter_email,item.variables.submitter_email);


email.addAddress("cc", item.variables.employee_email,item.variables.employee_email);



For reference : http://wiki.servicenow.com/index.php?title=Scripting_for_Email_Notifications#Adding_CC_and_BCC_Recip...



Cheers


Mohamad


Thanks, Mohamad!   This has been very helpful and I feel I'm almost there, but there are some stumbling blocks;



1.)   Only one of the addresses is being added to the CC field.   If I only leave one of the email.addAddress lines in the script it works...doesn't matter which one.   However, if I have both in the script, neither address is brought forward.



2.)   I would like the 'item.variables.submitter_email' value in the To field...not CC of BCC.   From what I found, the email.addAddress does not allow that and I have to pass that through to an event.parm.   Not sure how that is done, but am researching.



Another thing I tried to having the workflow combine the two submitter_email and employee_email into one field with them separated by a comma.   I then had the mail script add the value to the CC field.   No luck.



If I just had to have one address in the CC field, this would be a great solution, but I need more.   Any advice?


I used the parm1 and parm2 values to add email addresses to add contacts to the To: field in my notifications.



Although Mohamad's answer was partially correct, it got me in the right direction and opened other doors for me going forwards.   I'm still learning and I appreciate his direction.


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