Related list records in notification

Aditya2
Kilo Expert

Hi 

I have a requirement where I want to send notification for a change record. In the notification I want to display the Record Numbers in the Incidents Pending Change tab (where I can have maximum 3 records). I also want to display link, that will take me to the incidents.

find_real_file.png

How can I achieve this?

Thanking in Advance

AD

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

so you have notification on change_request table and want to include the INC in the related list tab shown

you will require email script for this and show the links and include that email script in your notification body

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

	// Add your code here
	var gr = new GlideRecord('incident');
	gr.addQuery('caused_by', current.sys_id);
	gr.query();
	if (gr.hasNext()) {
		template.print("Incidents: <br />");
		while (gr.next()) {
			var url = gr.getTableName() + ".do?sys_id=" + gr.getValue('sys_id'); 
			var attachLink = '<a href="' + url +  '">' + gr.number + '</a>';
			template.print(attachLink +  "<br />");
		}
		template.print("<hr/>");
	}

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

Regards
Ankur

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

so you have notification on change_request table and want to include the INC in the related list tab shown

you will require email script for this and show the links and include that email script in your notification body

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

	// Add your code here
	var gr = new GlideRecord('incident');
	gr.addQuery('caused_by', current.sys_id);
	gr.query();
	if (gr.hasNext()) {
		template.print("Incidents: <br />");
		while (gr.next()) {
			var url = gr.getTableName() + ".do?sys_id=" + gr.getValue('sys_id'); 
			var attachLink = '<a href="' + url +  '">' + gr.number + '</a>';
			template.print(attachLink +  "<br />");
		}
		template.print("<hr/>");
	}

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

Regards
Ankur

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

@Aditya 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

If not, please let us know if you need some more assistance.

Thanks!
Ankur

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