if will give current .update in before business rule , what will be happen?

ram2497
Tera Contributor

if will give current .update in before business rule , what will be happen?

1 ACCEPTED SOLUTION

Omkar Mone
Mega Sage

Hi 

Avoid using current.update() in a business rule script. Theupdate() method triggers business rules to run on the same table for insert and update operations, leading to a business rule calling itself over and over. Changes made in before business rules are automatically saved when all before business rules are complete, and after business rules are best used for updating related, not current, objects. When a recursive business rule is detected, the system stops it and logs the error in the system log. However, current.update() causes system performance issues and is never necessary.

Mark Correct if it helps.

Warm Regards,

Omkar Mone

find_real_file.png

www.dxsherpa.com

View solution in original post

5 REPLIES 5

Omkar Mone
Mega Sage

Hi 

Avoid using current.update() in a business rule script. Theupdate() method triggers business rules to run on the same table for insert and update operations, leading to a business rule calling itself over and over. Changes made in before business rules are automatically saved when all before business rules are complete, and after business rules are best used for updating related, not current, objects. When a recursive business rule is detected, the system stops it and logs the error in the system log. However, current.update() causes system performance issues and is never necessary.

Mark Correct if it helps.

Warm Regards,

Omkar Mone

find_real_file.png

www.dxsherpa.com

ScienceSoft
Tera Guru

Hi ram2497,

It's not recommended to use current.update() in before business rules because this is bad practice. 

For example, using current.update() in before update business rule can lead to recursion. 

But what is your business case? Maybe you need another solution.

georgimavrodiev
Mega Guru

Hello Ram,



If the Business Rule of yours runs before Insert or Update -> then, the system automatically does an update on the DataBase when the script runs - meaning that it doesn't need another current.update().

If you would like to read an interesting article about this topic, I would suggest you to review the following one:
"Never use current.update in a Business Rule" - https://community.servicenow.com/community?id=community_blog&sys_id=f12d66e5dbd0dbc01dcaf3231f961988 of Goran Lundqvist.


Best Regards,
Georgi Mavrodiev

IT Consultant
Do IT Wise Bulgaria

You may visit us in our Web Site: www.doitwise.com

Vivektietsood
Tera Guru
Tera Guru

current.update() however is required in async business rules. Please refer to the following question I asked in the community and the answers I got: 

https://community.servicenow.com/community?id=community_question&sys_id=c5b77865db758450414eeeb5ca96...