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

You're welcome Bryan.



In regards your last question... since it's not obvious for everybody reading the code that the "GlideRecord object will not get updated unless one of the values been set is different" I'll then recommend to keep the comparison. You will be providing much clarity to your code .



Thanks,


Berny


Great question by the way!