Updating records with AFTER business rules

Kris26
Tera Contributor

Hi, all

For a while now, I have been going through some of my company's SN configuration and coding to review some of the practices that have been in place up to now. This has been particularly relevant because of some performance issues overall and ''interesting'' bugs coming up from time to time.

So one thing I've found, the team seems to be using current.update() call in a LOT of business rules across the system, but in particular for some tables. I know that this has been covered in many places and topics already and is considered very bad practice - https://hi.service-now.com/kb_view.do?sysparm_article=KB0715782 or https://community.servicenow.com/community?id=community_blog&sys_id=f12d66e5dbd0dbc01dcaf3231f961988

Now, for the before business rule, everything is clear and that is a childish mistake that we can easily fix. My dilemma is with the after business rules, what would be the correct way of substituting current functionality and allow us to avoid the recursive calls that hinder performance and is very bad practice? I am also aware of setWorkflow(false) function. I would like to know how to get rid of these for good, not putting in the workflow function, since that is supposed to be last measure in exceptional cases anyway.

 

So let's model a situation - we have a table of records, and some BR associated with it. When the record is updated or inserted, it triggers the BR, which changes, updates some fields of that current record. This can only be done after the DB action, though, because we want to make sure the initial change has been allowed and successfully posted to the DB.

 

For example - Document A is created, document approver field is filled in and you click on submit button. This would trigger a business rule after the insert/update is made and set the document stage from ''draft'' to ''in progress''. How would you go about this? Would appreciate if you could also shed some light on async type BR, when that would be best applied.

10 REPLIES 10

Runjay Patel
Giga Sage

Check out this video, it will clear all your doubts and help you to understand Business Rule queries in details.

Link: https://www.youtube.com/watch?v=hLottNnk21U&ab_channel=ServiceNowHelpdesk

It help you to understand below points.

  • Scenario based business rule uses
  • Best business use cases for all types of business rules
  • Current .update in before business rule
  • Difference between Before BR and Before query BR?
  • Where can we use query business rule?
  • All type of business rule with real world scenario
    • Before
    • After
    • Async
    • Display

 

Please mark reply as Helpful/Correct, if applicable. Thanks!!