Announcing the Global SNUG Board of Directors. Learn more here
‎08-25-2007 11:07 AM
Wanted to take a moment to discuss the different between before and after business rule.
When a record is updated in since of Service-now, operations occur in this sequence:
Before business rules run -> Actual database write occurs -> after business rules run
To give a concrete example, if you press "update" while looking at an incident:
1) All "before update" incident business rules run
2) SNC actually posts your update into the database
3) All "after update" incident business rules run
What this means to you as a script writer is that you can do different things with before and after rules.
Before Rules:
Since they run before the physical update, any changes you make to the record during the rule are recorded as part of the update. This makes before rules the ideal place to set values as part of the save cascade. On the other hand, at the time the before rule is running, the current set of changes hasn't yet written through to the database, and may not be, e.g. the update could be cancelled because of missing mandatory fields, other business rules, etc.
After Rules:
Since they run after the physical update, any changes you make to the record during this rule will not be reflected in the database. This means this is a bad place to set values. On the other hand, at the time this rule runs, your database update has written through, so this is the right place to do things like throw custom events.
Summary:
‎07-01-2008 03:28 PM
Thanks for the explanation Pat. I have a much better idea of what these should be used for now.
‎07-02-2008 06:43 AM
This is also useful information from the wiki.
The order of execution is as follows:
‎05-19-2017 06:20 AM
Thanks , this is useful.