Issue in trigger the business rule ( overriding of BR)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 01:27 AM - edited 08-19-2024 01:29 AM
Hi team , i have below 2 business rules ,
BR 1: Before Insert, order 100
IF Item requested is either Microsoft Visio or Microsoft Project 365 & Short Des says "License Check"
THEN Change Catalogue Task state to Closed Incomplete
(function executeRule(current, previous /*null when async*/ ) {
//gs.sleep(5000);
if (current.state != 4) {
current.state = 4; //Update the state to 'Closed Incomplete'
}
})(current, previous);
BR 2: After Insert, order 200
IF Item requested is either Microsoft Visio or Microsoft Project 365 AND catalogue state changes to Closed Incomplete
THEN
Change Catalogue state to Work In Progress
Change Assignment Group to "SD TEST)"
(function executeRule(current, previous /*null when async*/) {
//gs.sleep(5000);
if (previous.state != 4 && current.state == 4) {
current.state = 2;
current.assignment_group.setDisplayValue('SD TEST');
current.update();
}
})(current, previous);
It seems that both business rules executed, but the change of state to 'Closed Incomplete' wasn't recorded in the Task's history and didn't complete the RITM workflow.
I tried by deactivate the second business rule, the first one triggers and successfully closes the RITM. However, when both business rules are active, the second business rule overrides the first. and set the task state to working in Progress.
Kindly help here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 03:21 AM - edited 08-19-2024 03:24 AM
The second script is doing what it's told - the current state is Closed Incomplete, so it's changing the state to WIP. Are you saying you want the workflow to complete, then change the State back to WIP? That won't work, because the workflow won't be running. If you don't want it to be WIP, check your logic and change this to
if (previous.state != 4 && current.state != 4) {
or take out the second condition since it's in the Filter Conditions, if that's what you're really trying to do. Better yet, combine these into one Business Rule, moving the difference in Filter Conditions to an if statement in the script, then you can see what's happening by logging one script, not triggering other rules.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 04:55 AM
Thank you for your reply. I'd like to understand why the first business rule, which should close the task as ' Closed Incomplete,' isn't being recorded in the Task history and is instead directly setting it to 'WIP.' I'm trying to understand the process better, so any insights would be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 05:21 AM
Hi @Bindhu1
BR1 (order = 100) : - This business rule sets the state to "Closed Incomplete" before the record is saved to the database. Because it is a Before business rule, the state is set directly on the new record during the insert operation. Since this is the first state that the record has upon insertion, it's not recorded as a change in the history (there's no "from" state to record the change).
For testing you can change BR1 to an After Insert business rule would ensure that the state change to "Closed Incomplete" is recorded in the history and the workflow can react to it.
Also keep consider the point mentioned by 'Brad'.
I hope my answer helps you to resolve your issue, if yes mark my answer helpful & correct.
Thank you
rajesh