- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 12:26 PM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 12:32 PM
i wonder if you can add a current.setWorkflow(false) to stop the other business rules from processing...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 12:30 PM
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 12:32 PM
i wonder if you can add a current.setWorkflow(false) to stop the other business rules from processing...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 12:41 PM
Thank you! That worked brilliantly!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2019 10:16 PM
This was still an issue for me on London Patch 8. Using current.setWorkflow(false) alongside current.setAbortAction(true) worked for me.