current.update() is not used in which business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 08:45 PM
current.update() is not used in which business rule and why?
Please tell me the exact reasons
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 08:54 PM
Hi @Basha4 ,
Please refere to the below mentioned serviecnow knowledge article for better understanding.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0715782
I hope this helps.
Please mark the response as helpful if this helps and Accept if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 08:59 PM
Hello @Basha4 ,
current.update() function should be avoided within any Business Rule, as there is almost always a work-around or another way to perform the needed task and it's use in a Business Rule can cause performance issues in the instance.
Also using it sometimes can make the business rule run in loops and thus taking a long time to update the record.
For more information and a workaround you can view the below article.
Recommended Practices in Using current.update() in Business Rules
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 09:06 PM
Hi @Basha4
Business Rules Technical Best Practices Overview
- Ensure the when the field is thought through when writing the BR.
- Use Async instead of after if the values that you are updating does not need to be shown immediately to the user.
- Use Conditions in BR: Since Business Rules are evaluated whenever an insert, update, delete or query action is made to a record, it is important to ensure you are using conditions. Conditions are evaluated before the rule is executed, if the condition is met, the script is evaluated and executed. If there is no condition, the system assumes that the Business Rule should be evaluated and executed for every action to a record on the specified table of the Business Rule.
- Enclose the code in functions: By default, an advanced Business Rule will wrap your code in a function, and it is important that this guideline is followed. When the code is not enclosed in a function, variables and other objects are available to all other server-side scripts.
- Prevent Recursive Business Rules: Do not use current.update() in a Business Rule script. The update() method triggers Business Rules to run on the same table for insert and update operations, potentially leading to a Business Rule calling itself over and over. When a recursive Business Rule is detected, ServiceNow stops it and logs the error in the system log.
- Use BR to double check any critical inputs.
- Use Script Includes instead of Global Business Rules: A global Business Rule is any Business Rule where the selected Table is Global. Any other script can call global Business Rules. Global Business Rules have no condition or table restrictions and load on every page in the system. There is no benefit to loading this kind of script on every page. Script includes load only when called.
You may also refer on this original community post ServiceNow Development Best Practices
Please mark the response as helpful if this helps and Accept if this solves your issue.
Regards,
Jeff