- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-27-2022 01:34 AM
I have written a BR in hr task table to close the parent case once the child HR tasks are getting closed. I have written the below script and instead of changing the state to Close Complete the parent case is getting moved to Awaiting Acceptance state. The backend value of Closed complete is 3 and its not taking the value.
(function executeRule(current, previous /*null when async*/ ) {
var hrtask = new GlideRecord('sn_hr_core_task');
hrtask.addQuery('parent',current.parent);
hrtask.addActiveQuery();
hrtask.query();
if(!hrtask.next()){
var hrcase = new GlideRecord('sn_hr_core_case');
hrcase.addActiveQuery();
hrcase.addQuery('sys_id',current.parent);
hrcase.query();
if(hrcase.next()){
hrcase.state= '3';
hrcase.work_notes = "Case closed as all to-dos are completed";
hrcase.update();
}
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-28-2022 12:19 AM - edited ā10-28-2022 12:20 AM
Hello @Suvetha S,
Please open the HR service record which and select 'Skip Automatic User Acceptance State' in Case Options field. Below is snapshot for reference. You don't need to make nay change in script.
Please mark correct/helpful if it helps you.
Regards,
Vinay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-27-2022 04:12 AM - edited ā10-27-2022 04:13 AM
Hi,
Can you please try this script
var hrtask = new GlideRecord('sn_hr_core_task');
hrtask.addQuery('parent',current.parent);
hrtask.addQuery('state','!=',3);
hrtask.addActiveQuery();
hrtask.query();
var count = hrtask.getRowCount();
if(count==0)
{
var hrcase = new GlideRecord('sn_hr_core_case');
hrcase.addActiveQuery();
hrcase.addQuery('sys_id',current.parent);
hrcase.query();
if(hrcase.next()){
hrcase.state= '3';
hrcase.work_notes = "Case closed as all to-dos are completed";
hrcase.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-27-2022 04:31 AM
@Hari haran I tried the above script. Its still the same. Parent case is going to Awaiting Acceptance state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-27-2022 05:28 AM
Hi,
Can you please share screenshot of form after task is updated?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-27-2022 05:31 AM