Having trouble with a Business Rule not firing.

allentschumper1
Tera Contributor

Here's my business rule script...

 

(function executeRule(current, previous /*null when async*/) {
    var carrierOnboardingGR = new GlideRecord("x_freight_csm_carrier_onboarding_cases");
    if (carrierOnboardingGR.get(current.carrier_cases)) {
        carrierOnboardingGR.carrier_account = gs.getProperty("x_freight_csm.co.ntp.account.id");
        carrierOnboardingGR.update();
    }
})(current, previous);
 
Running as AFTER > Update.  
the property houses the sys_id of the value that is supposed to go into the Carrier Account field.  it doesn't seem to be doing the trick.  
 
Any suggestions?
2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, unfortunately your post has no details of your configuration or debugging which makes ability to assess minimal.
What exactly is 'current.carrier_cases' ? Based on your code it would need to be a reference field IE 1 sys_id, but the name 'cases' implies more than 1 record ie a slushbucket/list?
If a list and you are expecting current.carrier_cases to contain multiple values you would need to use a glide query to lookup multiple records and a while(carrierOnboardingGR.next()) to loop through results, not a singular 'get'.

What are the results of your debugging.
Is the Br triggered?

Is a record returned by carrierOnboardingGR IE is the 'if' condition met?
If the if condition is met and x_freight_csm.co.ntp.account.id contains a sys_id that is valid for carrierOnboardingGR.carrier_account? then the most likely cause is that the update process is aborted or your carrierOnboardingGR.carrier_account value is overwritten during the update by another BR or flow\workflow.

 

Perhaps you could clarify your configuration and results of your debugging, so that the community can better understand your issue.



Sandeep Rajput
Tera Patron
Tera Patron

@allentschumper1 The best way to debug and check to see why the business rule is not triggering is via Script Tracer.

Screenshot 2024-07-04 at 8.18.19 AM.png

The script tracer shows the scripts BR/Script includes which get called during an operation. Using script tracer, you can check up to which order the business rules are executing and check if any business rule is using current.setWorkflow(false); if you see this line anywhere in any of the business rule in sequence which means the subsequent business rule won't get called.