[SalesForce] Old and New Values of Parent fields with Re-parenting on Child Trigger

I know we have to query the parent fields to access them on the child object trigger. How can I get the old and new values of the parent fields when its parent record has been changed. I have two objects.

  • Case (Child of Look-up to WebID Object)
  • WebID

I need to access old and new value of the Status__c custom field on WebID__c whenever Case gets its parent WebID Changed. Any inputs on the single line logic to retrieve the old and new values of parent field WebID__r.Status__c?

Thanks in Advance!

Best Answer

I would recommend creating a map of WebIDs to it's Status by querying the WebID object after creating a set from the old and new ids using the WebID__c field from the old/new child records. Then you can use that map to access the status of the WebID record based on the ID of the old record vs the new record.

Related Topic