Auto close the interaction record when the associated inc/req is closed

suryaogeti1
Tera Contributor

we have a requirement, when the incident or request is closed, automatically the interaction record needs to close. Already we have a Ui button in SOW interaction form, when we click the button in the interaction form, the incident or request will create. here in incident the associated interaction record is updating in the work notes. now the client wants additional changes which i mentioned in the first line. how can we achieve, please help with the process and the script. 
Thanks in advance

1 ACCEPTED SOLUTION

HI @suryaogeti1 ,
1.The configuration should be like this , add filter conditions as per requirement
Screenshot 2026-04-15 at 9.55.16 PM.png

2.Script:

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

	var gr=new GlideRecord("interaction_related_record");
	gr.addQuery("document_table","sc_request");  //updated table name
	gr.addQuery("document_id",current.sys_id);
	gr.query();


	if(gr.next())
	{
		var interaction=new GlideRecord("interaction");
		if(interaction.get(gr.getValue("interaction")))
		{
			interaction.state="closed_complete";
			interaction.update();
		}
		
	}


})(current, previous);



View solution in original post

12 REPLIES 12

Ankur Bawiskar
Tera Patron

@suryaogeti1 

it's a configuration available in SOW

55.png

for REQ see if that works, if not then write after update BR and query "interaction_related_record" and search and close Interaction

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hi @Ankur Bawiskar 
Thank you

@suryaogeti1 

So what worked for you since you marked response as correct?

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