How To bypass the Before Business Rule and make the Flow Designer run to cancel the change

Udhayakumar_30
Tera Contributor

I have created one "Before "Business Rule-

var AssignmentGroupM = false;
    var currentUser = gs.getUser();
    AssignmentGroupM = currentUser.isMemberOf(­current.assignment_group.getDisplayValue());
    if (!AssignmentGroupM) {
        gs.addErrorMessage('Change Can't be  cancel. ');
        current.setAbortAction(true);
    } else {
        current.work_notes = 'Change cancelled.';
    }  which is required as per requirement. 
 
The thing is I have to cancel the Change request by a "Flow Designer" which is preventing by this Business. I  want the Business Rule to be active as well. How I can bypass the Business Rule and cancel the change request. Is there any workaround or any suggestion?
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Udhayakumar_30 

add this in the condition of the BR

gs.getSession().isInteractive()

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

@Udhayakumar_30 

add this in the condition of the BR

gs.getSession().isInteractive()

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

 Here is the condition 

 

if (gs.getSession().isInteractive()) {

var AssignmentGroupM = false;
    var currentUser = gs.getUser();
    AssignmentGroupM = currentUser.isMemberOf(­current.assignment_group.getDisplayValue());
    if (!AssignmentGroupM) {
        gs.addErrorMessage('Change Can't be cancel only Members can close. ');
        current.setAbortAction(true);
    } else {
        current.work_notes = 'Change cancelled.';
    } }
 
is there anything i wanna change.Please let me know
 

@Udhayakumar_30 

when you add that interactive check the BR should not run when flow executes.

Did you check the other BR which is blocking the update "Cancel note"?

I believe the BR you shared is not blocking the update from flow.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

When I deactivate the flow, i have created the flow runs and the change get cancelled.