Fields in Email Notification

ryan86
Kilo Expert

Hi all,

 

(I'm new to ServiceNow)

 

I am looking to create an email notification, which sends an email to HR when we are notified a user is leaving the company.

I have an event in place, and the email notification is triggered and sent.

 

However, the issue I have is with the content of the email. When a user completes an online form within our portal, I have a reference field named "leaver". I need to capture this value, and include it within the email to HR. I thought it would show within the "fields" group, but it doesn't. Can I make it appear in there?

 

All help appreciated.

 

Ryan

1 ACCEPTED SOLUTION

solutioningnow
Giga Guru

Hi Ryan,



I assume 'leaver' field is on online catalog item or record producer. Variable created on the catalog item or record producer are not accessible directly on the email. To pull value of variable in the email template, you will have to write below code.



<mail_script>template.print(current.variables.leaver.getDisplayValue())</mail_script>



Please mark answer as Helpful/Correct, if it was really helpful 🙂



Regards,


Solutioner


Logo.png


Enhance Knowledge NOW@ www.solutioningnow.com


http://www.solutioningnow.com/


View solution in original post

6 REPLIES 6

Hi Ryan,



I think the mistake in my script was on line 8. Replace current.sysapproval with current.sys_id and try again. I'm assuming that your notification has been set to run on the Requested Item table?


I was just playing around with your code and noticed that I am getting populated with 'sys_id' for reference type of variables.


By any way can we get DisplayValue for reference type by using your script?