Using BR need to trigger the Flow.

Barathk
Tera Contributor
Hi All,
I am try to create RITM using the Cart API using BR.
I add the condition is item name.
once the item is submitted using the below script the RITM is need to be create.
Note : Now the BR is triggered multiple times and creating Multiple RITMs.
can any help to fix this issue.

(
function executeRule(current, previous /*null when async*/) {

gs.info("Iam Testing");
var cart = new sn_sc.CartJS();
var item = {
'sysparm_id': '3456787334126503d60c567ed5c7b8e',
'sysparm_quantity': '1',
'variables': {
'city': current.variables.city,
}
};
cart.setRequestedFor('e34340335566433xb5a9ed5c7bc9');
cart.addToCart(item);
var checkoutInfo = cart.checkoutCart();
})(current, previous);
3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Barathk 

then please check with the customer when should this BR run and add appropriate conditions

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

Robert H
Mega Sage

Hello @Barathk ,

 

Which table is the Business Rule defined on, and what is the trigger type (before/after/async?, insert/update?) and condition?

And what is the actual issue - something with the Flow (as mentioned in the subject of your post) or something about duplicate requests?

 

Regards,

Robert

Rajesh Chopade1
Mega Sage

hi @Barathk 

Ensure the BR is triggered only once for the intended event. For example, set the BR to run on the Insert operation of the specific table (e.g. sc_req_item) and avoid running on Update unless necessary. If the BR runs on Update, recursive updates (e.g., updates to current or related records) can cause it to trigger repeatedly.

 

Also check other business rules, workflows, or scripts might be updating the same record, causing your BR to trigger multiple times.

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh