Business rule condition is skipping

harishdasari
Tera Guru

Hi ,

I will tell you the scenario

First user will raise a request in service catalog, Now it will route for his manager approval and after manager approval it will route for Group approval.

Now in group approval, if they want to add another group as well to approve this request then they manually add the group by click on Add Approval group as shown in screenshot.

find_real_file.png

So now workflow should wait for approval from Both the groups. the one which workflow is routed for and another approval is from the group which will be added manually.

so to check this functionally we have written the business rule below I been mentioned. It was working good till Helsinki. But After up-gradation to Jakarta it is not waiting for approval from manually added group and it is marking state as "No Longer Required"

find_real_file.png

I have tried to debug the session it is showing like Business rule is skipping the condition.

Script is running on Approver table.

Condition of Business Rule:   current.sysapproval.sys_class_name == 'sc_req_item' && (current.state == 'approved' || current.state == 'rejected') && current.group != ''

Business rule:

//Make sure this approval request is created by "Add Approval Group" on Requested Item form

var checkAddGroup = new GlideRecord('u_m2m_groups_requested_items');

checkAddGroup.addQuery('u_group',current.group.assignment_group);

checkAddGroup.addQuery('u_requested_item',current.sysapproval);

checkAddGroup.query();

if(checkAddGroup.next())

{

    //Mark No Longer Required for remaining group member's approval request.

var approval = new GlideRecord('sysapproval_approver');

approval.addQuery('group',current.group);

approval.addQuery('sysapproval',current.sysapproval);

approval.addQuery('state','requested');

approval.query();

while(approval.next())

{

approval.state = 'not_required';

approval.update();

}

}

Thanks.

2 REPLIES 2

Anurag Tripathi
Mega Patron
Mega Patron

Hi Hari,



The condition looks okay, can you just confrirm the following things



1) Add log in the first line of the br to ensure that br is bot executing


2) Group is blank



Also, Can you play around with the order field to ensure that when the BR is evaluated, at that time the condition should be completely done.


-Anurag

Hi Anurag,



Thanks for responding to my thread.



I have tried your suggestions by changing the order number, it is not working.



I have put the logs, yes code is working... But by default it is setting as No longer required.



can you please give me clue like why this might be behaving some thing differently in different versions.



I have tested in helsinki which is running in sandbox and DEV instance is running on DEV instance.



Thanks