Came across this post in the forums the other day:
I have a one-to-many relationship between a custom module and Contacts. I’ve added a before_save logic hook to the custom module, and I need to be able to check if the related Contact has changed. For all other fields, I can accomplish this by comparing $bean->fieldname to $bean->fetched_row[‘fieldname’]. However, the relationship id value (my_modulecontacts_ida) does not appear in the fetched_row array. I have a value for $bean->my_modulecontacts_ida, but there is no $bean->fetched_row[‘my_modulecontacts_ida’], so the two are never equal. How can I fetch the old value of my_modulecontacts_ida?
The poster is right here; $bean->fetched_row only contains the fields on the primary module record itself, and doesn’t handle those in related fields. But as poster shyam007 points out, you can look in the $bean->rel_fields_before_value array instead for these. Hopefully this tip helps other’s struggling for a way to do this.