Not applicable

Hi @vinuth v 

 

We should avoid current.update() function in Business rules. Main reason to avoid update function in BR is that it can lead to recursive call to same business rule. Servicenow has internal detectors for this but to prevent an endless recursive call of BR can cause performance issue in instance.

There is almost never a case when the current.update() should ever need to be used in an Business Rule. Lets discuss each type of business rules one by one.

🌟current.update() in Before Business Rule?

In Before BR current.update is not necessary as SNOW saves all values stored in current object after BR executes.

Eg : current.state = 7 ; current.description=”hello there”;

🌟current.update() in After Business Rule?

In After BR try to rethink about using current.update() as this can cause Before BR run again. To avoid this, change your After BR to Before BR so you won’t need to use current.update.

🌟current.update() in Async Business Rule?

Async BR executes after data is modified in database, so its solution is similar to After BR.

🌟current.update() in Display Business Rule?

Display BR runs when record is first displayed on the screen. So, it is not a good practice to update record when it is just accessed. Alternatively use client scripts in those cases.

🌟When to use current.update()?

In the rare case in which a current.update() cannot be avoided, in order to prevent recursion that can cause preformance issue then current.update should be used in conjuction with setWorkflow(false).

current.status = 1;
current.setWorkflow(false);
current.update();
current.setWorkflow(true);
This will suppress any business rules from triggering and will also prevent the update from being audited.

So this is all about usage of current.update(). You can take you own changes and try to avoid using the function.
 
 
Regards,
Amit