Autopopulate all affected cis in related list of change request to change task related list affected cis

Harsha Pandey
Tera Expert

Hi,

In change request, there is already a related list of affected cis, there can be multiple affected cis in this related list.

I want to populate all those affected cis in related list of change task affected cis. These change tasks are getting populated in change request at implement state in related list 'Change Tasks'.

Note: I can already see a related list tab in change task for affected cis, as we do not want another related list tab for affected cis.

Please suggest a business rule for this as we do not want a new relationship !!!!!!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use this logic to link those affected Cis to Change task

BR: After Update on Change Request

Condition: State [Changes to] Implement

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var rec1 = new GlideRecord("change_task");
	rec1.addQuery("change_request", current.getUniqueValue());
	rec1.query();
	while(rec1.next()){
		var gr = new GlideRecord("task_ci");
		gr.addQuery("task", current.getUniqueValue());
		gr.query();
		while(gr.next()) {
			var rec = new GlideRecord("task_ci");
			rec.initialize();
			rec.task = rec1.getUniqueValue();
			rec.ci_item = gr.ci_item;
			rec.insert();
		}
	}

})(current, previous);

Regards
Ankur

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

View solution in original post

5 REPLIES 5

Hi Ankur,

It is working for few changes but not working for other changes. It might be an issue with the existing configuration.

But thanks a lot. It worked!!!