Is it okay to use the form condition builder and not the condition field when using an advanced business rule?

Jon23
Mega Sage

Is there any reason not to use the form condition builder whenever possible even when using advanced script in a business rule? Am I safe to use both if needed?

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

brianrichards
Tera Guru

It's preferable to use the condition build to avoiding unnecessary scripting behavior, as well as to make the logic less prone to developer error. Typically either is fine, and the best advice is to remain consistent with your development practices from one BR to another.

The following is taken directly from the Training Plan lesson on Business Rules:

"Use the Condition field to write Javascript to specify when the Business Rule script should execute. Using the Condition field rather than writing condition logic directly in the Script field avoids loading unnecessary script logic. The Business Rule script logic only executes when the Condition field returns true. If the Condition field is empty, the field returns true.

There is a special consideration for async Business Rules and the Condition field. Because async Business Rules are separated in time from the database operation which launched the Business Rule, there is a possibility of changes to the record between when the condition was tested and when the async Business Rule runs. To re-evaluate async Business Rule conditions before running, set the system property, glide.businessrule.async_condition_check, to true. You can find information about setting system properties on the ServiceNow docs site."

View solution in original post

1 REPLY 1

brianrichards
Tera Guru

It's preferable to use the condition build to avoiding unnecessary scripting behavior, as well as to make the logic less prone to developer error. Typically either is fine, and the best advice is to remain consistent with your development practices from one BR to another.

The following is taken directly from the Training Plan lesson on Business Rules:

"Use the Condition field to write Javascript to specify when the Business Rule script should execute. Using the Condition field rather than writing condition logic directly in the Script field avoids loading unnecessary script logic. The Business Rule script logic only executes when the Condition field returns true. If the Condition field is empty, the field returns true.

There is a special consideration for async Business Rules and the Condition field. Because async Business Rules are separated in time from the database operation which launched the Business Rule, there is a possibility of changes to the record between when the condition was tested and when the async Business Rule runs. To re-evaluate async Business Rule conditions before running, set the system property, glide.businessrule.async_condition_check, to true. You can find information about setting system properties on the ServiceNow docs site."