Project tasks and child task with checklist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2023 02:37 PM
Hi , so lets consider L1 as parent project task(task under project) and L2 as child project task(task under L1) now I have to implement a scenario where
a)L1 state is not allowed to closed complete if there are incomplete checklist under itself or under its L2
b)Similarly L2 is not allowed to closed complete if there are incomplete checklist under itself or under its L1
To achieve the above I have written an befor update BR with script but it was not working as expected at order 100 as some other BR was cutting it hence changed the order to 910 and it works now.
But the problem is ,everytime state changes to closed complete on L2 bec of Out of box rollup it tries changing L1 to closed complete too bec of which my BR runs twice and parents error appear on child task .
Also get duplicate errors .I have tried finding differentiator between l1 and l2 but that does not stop the double runing
Any solution to handle this situation. Kindly help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2023 02:39 PM
Pating the SCript Include method used for details:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2023 10:53 PM
Hi @Aishwarya Pulas ,
Can u try below code plz
(function executeRule(current, previous /*null when async*/ ) {
// Check if the Business Rule should run based on the record state
if (current.state != 'Closed Complete') {
var parent = current.parent.parent;
var ptaskno = current.number;
if (parent) {
// Actions for 'pm_project'
if (new projectTaskServerUtil().checkOpenCheckList(current.sys_id)) {
// Temporarily update the record to prevent the Business Rule from running again
current.setWorkflow(false); // Disable workflow to prevent unnecessary triggers
current.state = previous.state; // Restore the previous state
current.update();
current.setWorkflow(true); // Re-enable workflow
gs.addErrorMessage("Please close all checklists on " + ptaskno + " before closing.");
}
} else if (!parent) {
// Actions for 'pm_project_task'
if (new projectTaskServerUtil().checkOpenCheckList(current.sys_id)) {
// Temporarily update the record to prevent the Business Rule from running again
current.setWorkflow(false); // Disable workflow to prevent unnecessary triggers
current.state = previous.state; // Restore the previous state
current.update();
current.setWorkflow(true); // Re-enable workflow
gs.addErrorMessage("Please close all checklists on " + ptaskno + " before closing.");
}
}
}
})(current, previous);
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 05:55 AM
So , the running of the BR twice stopped when I used the Abort Action .But I aslso want to redirect them to the record with error. But I see in few articles that combination of abortAction and gs.rediect dont work. Any workaround ?
Business Rule :