when request is cancelled Send notification to Requester and assigned to members also?

suresh40
Tera Contributor

Hi All,

I have 2 different tables parent and child . If any one user click the cancelled button on the request notification has to send t0 both parent record and child records assigned to members. Please help me on this.

 

Thanks,

Suresh

3 REPLIES 3

Mohit Kaushik
Mega Sage
Mega Sage

Hi Suresh,

You can do it with the help of a business rule and Event Queue method.

1. Create an event in event registry table.

2. Create a business rule on request table and put the condition when state changes to cancel and write the below script in advance section of your BR.

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

	// Add your code here
    var childAssignedTo = [];
	var ritm = new GlideRecord('sc_req_item');
	ritm.addQuery('parent',current.sys_id); // or ritm.addQuery('request',current.sys_id);
	ritm.query();
	while(ritm.next()){
		childAssignedTo.push(ritm.assigned_to);
	}
	
	gs.eventQueue('name of the event',current,current.assigned_to,childAssignedTo.toString());
	
})(current, previous);

3. Now you can create a notification on Request table, which will be triggered when the event is fired.

 

Please mark this as correct and helpful if it resolved the query or lead you in right direction.

Thanks,
Mohit Kaushik
Community Rising Star 2022

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Hi Mohit,

 

Sorry for the late reply,

In Parent table I have multiple child Task , If any one task state is close complete and another 2 task is in Open state . In parent table any one click on cancelled button notification has to send All SC task assigned to members (close complete state also). Please help me on this. 

Thanks,

Suresh.

 

Hi Suresh,

When you say child task does that mean catalog tasks or RITMs.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)