Add Change Requests list item to an email or notification

Joel O
Mega Sage

Hi everyone, 

 

Scenario:
I have a situation where, when a specific catalog item is submitted within the RITM there is a specific task that requires the RITM to be converted to a CHG ticket. The converted CHG ticket gets added to the Related List - Change Requests within the RITM (see attached). Once all SCTASKS are completed, the closure of RITM/REQ will happen in accordance and a email communication will be sent to the submitter informing of the CHG ticket #. 

 

In my Flow, I'd like to send forth an email notifying of this conversion however, I'm unsure on how I can add the CHG Ticket # as there is no data pill available for Related Lists (that I can see). Then I looked into sending an email notification instead and see if that would be possible however, short of my knowledge of scripting, I'm not familiar on how to accomplish. I also reviewed my option from sending it when the Change is created and the Parent field is populated (Trigger), to which can work but the RITM/REQ has not completed as of yet and that is not ideal within the process. 

 

I'm leaning to questioning the process of why and when to convert but that's a further business discussion. However, given at this time the converting of RITM > CHG is a manual step, I'd like to ask the assistance of the community on how best for me to add the Related List - Change Request ticket # to email communications, whether via Flow or through email notifications? OR maybe another solution on how I can best communicate to the submitter (maybe I'm overthinking it).

 

Thank you all! 

1 ACCEPTED SOLUTION

Alex Rose
Tera Guru

Hi Joel,

 

In order to add the associated Change Request number(s) to your email communications about the RITM, I would create a new notification email script.  In the script, you can look up change requests that are associated with the RITM, then print their number.  For example:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

		  var gr = new GlideRecord('change_request');
		  gr.addQuery('associated_ritm', current.sys_id);
		  gr.query();
		  while(gr.next())
		  {
			template.print(gr.number + " ");
		  }

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

Note you'll have the change the query to however you associated the change request to the RITM, you probably had to write something like that to get the related list working.
Then, in your email notifications for RITMs, insert ${mail_script:<script_name>}.

View solution in original post

2 REPLIES 2

Alex Rose
Tera Guru

Hi Joel,

 

In order to add the associated Change Request number(s) to your email communications about the RITM, I would create a new notification email script.  In the script, you can look up change requests that are associated with the RITM, then print their number.  For example:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

		  var gr = new GlideRecord('change_request');
		  gr.addQuery('associated_ritm', current.sys_id);
		  gr.query();
		  while(gr.next())
		  {
			template.print(gr.number + " ");
		  }

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

Note you'll have the change the query to however you associated the change request to the RITM, you probably had to write something like that to get the related list working.
Then, in your email notifications for RITMs, insert ${mail_script:<script_name>}.

Thanks @Alex Rose, this worked!