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

@Udhayakumar_30 

yes condition is fine which you added.

Seems there is a conflict in your requirement.

if your BR is blocking the insert/update then your flow should not set those field values and it's conflicting your business requirement.

Please discuss this with your customer.

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

Any workaround is there for this requirement?. 

 

 

@Udhayakumar_30 

Consider it like this

1) your BR stops the update based on Condition and validation

2) if your FLOW is doing what is not a valid usecase the BR will stop.

Please discuss this with your customer.

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

Is "Cancel Note" the name of the business rule who's script you're posting?

GlideFather
Tera Patron

Hey

it seems like not all the mandatory fields are populated, can you ensure everything needed is populated?

try to cancel a change request manually to see what fields are required - state change, close notes..

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */