Business Rules on Two Tables with References To Each Other

Bryan13
Tera Expert

I have two tables where each has a reference to the other. I have created two Business Rules. One for table 1 that updates it's reference field in table 2. One for table 2 that updates it's reference field in table 1.

This causes both Business Rules to be called whenever a reference field change is made to either table. This is because each updates the reference field on the other table. Both Business Rules are triggered "after" "insert/update" of reference field.

I have logic to prevent unnecessary updates but there is still some overhead (insignificant probably...).

I am wondering if this is a situation that is avoidable or is it a somewhat common occurrence?

I hope my post is not too confusing. If so, I will try to clarify further.

Thanks.

1 ACCEPTED SOLUTION

Great! There's really no overhead in place with the approach you're taking. So you should be fine since the field only gets updated once at both tables.



Lets elaborate why:



By the time the on after business rule of the second table is executed, the value that it will attempt to change for the first table that initiated the change will be ignored since now the value will be the same at both tables. That's because within any glide record, at least one value has to be different in order for an .update() to be effective. Except when setForceUpdate is set to true for the glide record.



Thanks,


Berny


View solution in original post

6 REPLIES 6

bernyalvarado
Mega Sage

Hi Bryan,



Do you have a condition within your business rules so these are fired only when the field's value changes?



Thanks.


Berny


Yes, I have a filter condition set on when the reference field changes:bus-rule-condition.PNG


Great! There's really no overhead in place with the approach you're taking. So you should be fine since the field only gets updated once at both tables.



Lets elaborate why:



By the time the on after business rule of the second table is executed, the value that it will attempt to change for the first table that initiated the change will be ignored since now the value will be the same at both tables. That's because within any glide record, at least one value has to be different in order for an .update() to be effective. Except when setForceUpdate is set to true for the glide record.



Thanks,


Berny


Thanks for the clarification. Just one more question. Regarding the statement "at least one value has to be different in order for an .update() to be effective". Does this mean that a value check of the field being updated in the script is unnecessary - i.e. if (currentvalue != new value)?