HR case should not closed if any HR task is open

Jyoti Mehta
Tera Contributor

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);

13 REPLIES 13

Rob Sestito
Mega Sage

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:

find_real_file.png

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

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.

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

John Zhang1
Kilo Patron
Kilo Patron

I tested your code without "gs.getMessage()" and it works.

find_real_file.png

find_real_file.pngIf my reply is Helpful/Correct, please mark the answer as Helpful/Correct

Jaspal Singh
Mega Patron
Mega Patron

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.