33 views
How It Works
When you have a business rule that runs asynchronously, the actual execution of that script is delayed until one of the workers on your instance processes ASYNC: Background jobs from the sys_trigger table.

When the record is modified and the async rule is triggered, we add a record to the sys_trigger table. That record holds a reference to the business rule that we need to run, and to the particular record to use as current within that business rule. When the worker picks up the job, a scripting environment is created. The record is loaded from the database as it is at the time the script runs and is put into the scripting environment as the variable current. You can then interact with that variable as you normally would.
Recommendations
While you can modify the current record using the normal current.setValue('field_name', 'value') method or via direct assignment using current.field_name = 'value';, and you can update the record using current.update(), this is strongly discouraged. It is not good practice to modify the current record outside of a before business rule.

If the architecture of your application calls for current.update() in a business rule, this indicates poor application architecture. It points to a potential problem or incident waiting to happen, which could be avoided by only modifying the current record before it is written to the database.

Article Information

Last Updated:2018-06-15 16:20:55
Published:2018-06-15