HR case should not closed if any HR task is open
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 07:59 AM
Hi,
we have an requirement where a HR case should not be closed until all the HR tasks will be completed. For which we have created a onbefore business rule whenever case state changes to Resolved state then it should be abort and show error message.
we are facing issue for the error message : Here case is abort when click on resolved button but it is not showing the error message. Can anyone please check below script and suggest ?
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sn_hr_core_task');
gr.addActiveQuery();
gr.addQuery('parent',current.sys_id);
gr.query();
if (gr.next()) {
// gs.addInfoMessage("please close HR tasks first");
gs.addErrorMessage(gs.getMessage('please close HR tasks first'));
current.setAbortAction(true);
}
})(current, previous);
- Labels:
-
Case and Knowledge Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 08:20 AM
Hey Jyoti,
There is a condition you can put within the Condition field of the Close Complete UI Action that will make it hidden until all Tasks are completed and closed. And the UI Action will still appear when NO tasks are associated with it.
We have this for our HR Cases and it works just fine:
This way, the UI Action isn't even an option until Tasks are done first.
You could give this a shot and see if it works for you as well.
Cheers,
-Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2022 03:36 AM
Hi Rob,
we have this condition added for Resolved and Closed Complete UI action where closed complete UI action is not visible to assigned to person but Resolved UI action is visible to assigned to person.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2022 06:25 AM
Hey Jyoti,
I wanted to clarify real quick:
You are saying you have the condition within both UI Actions, but Resolved UI is still showing up on the form for the Assigned To person?
Thanks,
-Rob

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 09:39 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 09:44 AM
Hi,
I see experts already commenting on the thread but just a suggestion here why not include the business rule logic in the UI Action itself.