current.setAbortAction(true) not working for delete business rule

staceyrocheleau
Kilo Guru

I want to add a business rule to project tasks to prevent them from being deleted if there are time entries logged with hours to the task. I have created a business rule:

When: before
Delete: trueOrder: 1 (so that it runs before the out of the box before delete business rules)

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

....

  if (<condition to prevent delete>) {

  gs.addErrorMessage(gs.getMessage("You cannot delete a task where users have logged time against the task."));

  current.setAbortAction(true);

  }

})(current, previous);

This displays the error message but it always goes ahead and deletes the task. I've tried putting the abort action outside of the function and it still doesn't work. Any ideas as to why this is not aborting the delete? Is it the following business rules for "before delete"--are they still getting triggered regardless of my aborting the delete? I would have thought it would stop the action and not do anything.

Thanks!

1 ACCEPTED SOLUTION

i wonder if you can add a current.setWorkflow(false) to stop the other business rules from processing...


View solution in original post

4 REPLIES 4

staceyrocheleau
Kilo Guru

It turns out the other business rules get triggered so I would have to then modify 10 out of the box business rules to stop the delete from happening. I would have thought the abort stopped everything but the other rules still run and do the delete. Interesting...


i wonder if you can add a current.setWorkflow(false) to stop the other business rules from processing...


Thank you! That worked brilliantly!!!


OzZy M
Tera Contributor

This was still an issue for me on London Patch 8.  Using current.setWorkflow(false) alongside current.setAbortAction(true) worked for me.