Close all related Case Tasks when the case is resolved

erajakumaran
Tera Contributor

Hi,

We have a requirement where all related case tasks(sn_customerservice_task) should be auto closed when its parent case(sn_customeservice_case) is resolved OR not letting the agents to resolve the case until all its related case tasks are closed. 

On the community site I found something similar for Incident and its related Incident tasks where they have achieved it with a BR, I have tried using the same BR logic and edited according to the case and case task table but it doesn't work.


Appreciate if you could provide some BR script which could work.

2 ACCEPTED SOLUTIONS

Gangadhar Ravi
Giga Sage
Giga Sage

Hi @erajakumaran 

 

You can add something like below 

 

// Business Rule Script

var caseTasks = new GlideRecord('sn_customerservice_task');
caseTasks.addQuery('parent', current.sys_id); 
caseTasks.addQuery('state', '!=', 'closed');  
caseTasks.query();

if (caseTasks.hasNext()) {
    gs.addErrorMessage('The case cannot be resolved until all related tasks are closed.');
    current.setAbortAction(true);  
}

 

Please mark my answer correct and helpful if this works for you.

View solution in original post

Hi @erajakumaran ,

I just small modified the script that was provided by @Gangadhar Ravi  as below:

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

	// Add your code here
	// Business Rule Script

	var caseTasks = new GlideRecord('sn_customerservice_task');
	caseTasks.addQuery('parent_case', current.sys_id); 
	caseTasks.addQuery('state', '!=', 3);  
	caseTasks.query();

	if (caseTasks.hasNext()) {
		gs.addErrorMessage('The case cannot be resolved until all related tasks are closed.');
		current.setAbortAction(true);  
	}


})(current, previous);

Then, it seems running as below. the error message was shown as below:

aizawaken_0-1728650544924.png


But 1 thing I have to say to you, this works by checking the state is closed or not, instead of checking resolved. It is because I could not find the value of resolved...

Hope this would help you 🙂 

 

View solution in original post

11 REPLIES 11

aizawaken
Tera Guru

hi @erajakumaran 
As you mentioned, BR is one of the solutions, and I will choose this if I were you.

Set Update trigger onto the state field of "its parent case" table, and if it is changed to "resolved", then run the action that update the state of "case tasks".  If necessary, you should write a script in Advanced section.

Doesn't it work well?

Hi @aizawaken 

Thanks for your response.

 

Yes, already tried that but no luck.

 

Appreciate if you could provide some script which could work.

aizawaken
Tera Guru

hi @erajakumaran ,

On my PDI, I tried to test a Business rule as below.
The result is,,, still "ChangeRequest" related errors are appeared, but it seems that task's status can be changed.

 

aizawaken_1-1728572330148.png

 

aizawaken_0-1728572258031.png

What you need to do is like this, I hope.

Hi @aizawaken , 

 

I was trying to not let the case to be resolved when there are related active case tasks, however, updating the case tasks to be closed also will help.

What’s the best way to not to allow the cases to be resolved if the related tasks are still opened please? We could add few more lines to the BR script you have shared to abort the resolve action I think?