The CreatorCon Call for Content is officially open! Get started here.

How can we decide that a given 'before business rule' should be kept as it is or changed to 'after business rule'?

reeba1
Tera Contributor

Hello All,

According to ACE reports 'Before Business Rules' should not update() or insert() records on other tables. Now I have to decide whether I should keep the 'before business rule' as it is or change it to 'after business rule'. I wanted to know how to decide that.And I have a wierd code, it would be nice if someone could help me with this.

This business rule runs before insert and update and it is made on the table sysauto_db_check.The code is as shown below:

current.script = "var gr1 = new GlideRecord('ha_db_check');gr1.setValue('check_type',current.check_type);gr1.setValue('target_database',current.target_database);gr1.setValue('auto_repair',current.auto_repair); gr1.insert();";

Should this be kept as it is or changed to after business rule?

Regards,

Reeba

15 REPLIES 15

Thankyou Ulrich for solving my doubts. Have a nice day 🙂


Hi Reeba,



Yes you have to create an onAfter Business Rule for conditions like this, and this one of the good example for onAfter Business Rules.


Hi Ulrich,



Is there any way to know which scheduled job is triggering this business rule?



Regards,


Reeba


Ulrich Jugl
ServiceNow Employee
ServiceNow Employee

What are the conditions of the Business Rule looking like?


There is no condition. Its a before BR on insert and update and the first code that I posted. I'll post again.



current.script = "var gr1 = new GlideRecord('ha_db_check');gr1.setValue('check_type',current.check_type);gr1.setValue('target_database',current.target_database);gr1.setValue('auto_repair',current.auto_repair);gr1.insert();";