- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2024 04:10 PM - edited 10-08-2024 07:48 AM
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.
Solved! Go to Solution.
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 06:01 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 05:47 AM
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:
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 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 04:44 PM
hi @erajakumaran
> 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?
I got your point. Let me check it tonight 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 06:01 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 03:29 AM
Thanks for your response and the provided business script but it still let the cases to be resolved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 05:28 AM
@erajakumaran Can you share your current script. So that I can review.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 05:47 AM
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:
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 🙂