Background script doesn´t trigger business rules

MarcosBR
Tera Contributor

Hello people.

I am quite new on SN, only a year but previously when I change some data from Background scripts, it always run all the business rules with the match condition. But this time I see a new message that shows me the opposite.

3cd74cbf-5fd1-4bc1-adc6-d56c4db6ce46.jpg


Some insight about why is this happening? Thanks for your help.

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You are not using setWorkflow(false) which makes sure that BRs don't run for the transaction.

Only other thing I can think is , there is nothing getting updated, if there are no fields that get updated, the update is skipped and hence there will not be aby workflows running.

So try to add the below in your GlideRecord, this forces an update to the record even if no fields are changed.

gr.setForceUpdate(true); //Force the update

-Anurag

Robbie
Kilo Patron
Kilo Patron

Hi @MarcosBR,

 

I can see that you're performing a GlideRecord query on what looks like a scoped application. Can you confirm this? Please make sure when running the Background script you have the correct scope selected at the bottom of the Background script form.

 

If the scope is not available, you have the option of creating a Fix script in required application scope & then use it.

 

Best practice tip: I can see you are using the variable 'gr' for your GlideRecord call up. This is not good practice. It's best to call the variable something unique and something other than gr.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

 

Screenshot 2024-07-26 at 12.44.01.png

Sandeep Rajput
Tera Patron
Tera Patron

@MarcosBR It looks like your script is causing a recursion due to which the business rule is not called. Please verify your script and check which portions are causing a recursions.