How to get Variable detail in Notification Script

shaik_irfan
Tera Guru

Hi,

I have a Notification Script designed now i want to get the variable details in Notificaiton script can anyone please help me on this

7 REPLIES 7

Mark Roethof
Tera Patron
Tera Patron

Hi there,

In the Message HTML of Notifications, you could use something like below to display the value of a variable:

${variables.your_actual_variable_name}

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thank you very much!!

Jaspal Singh
Mega Patron
Mega Patron

Hi Irfan,

 

Try using below snippet in your mail script & then call the mail script in mail body of notification.

Mail Script: getVariables.

(function runMailScript(current, template, email, email_action, event) {
	
	// Add your code here
	template.print("<b>Summary of Requested items:\n</b>");
	var item = new GlideRecord("sc_req_item");
	if (item.get(current.request_item.sys_id)) 
               {
		template.print(item.number + ": " + item.cat_item.getDisplayValue() + "\n");
		var keys = new Array();
		var set = new GlideappVariablePoolQuestionSet();
		set.setRequestID(item.sys_id); 
                set.load();

		var vs = set.getFlatQuestions();
		for (var i=0; i < vs.size(); i++) 
                         {
                           if(vs.get(i).getDisplayValue() != '')
                              {
				
				template.space(4); template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");
				
			}
			
		}
		
	}
	
})(current, template, email, email_action, event);

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

Hi,

 

I have the similar requirement but this code is not working for me. could please help