RITM catalog item variables to use in Notifications..

Kruthik M Shiva
Tera Contributor

Hi All,
I have a catalog item once the form is created an RITM will be created and then based on status of RITM I am creating few notifications on RITM table. But in the notification, I need to use variables of catalog item, but I am not finding in select variables of notification can anyone please provide email script to fetch variables of catalog item in notifications subject and body from RITM.
Thanks in advance.

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Kruthik M Shiva 

check this script and try to enhance it further

(function runMailScript(current, template, email, email_action, event) {

	// Add your code here

	template.print('Variable Summary: <br/>');

	var ritm = new GlideRecord('sc_req_item');
	ritm.get('request', current.sys_id);

	var variables = ritm.variables.getElements(); 
	for (var i=0;i<variables.length;i++) { 
		var question = variables[i].getQuestion();
		var label = question.getLabel();
		var value = question.getDisplayValue();
		if(label != ''){
			template.space(4);
			template.print('  ' + label + " = " + value + "<br/>");
		}
	} 

})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader