I have four custom objects. Three objects are linked to the fourth (main) object via a lookup. The fourth main object has an email field. I am looking to auto copy the value of the email address field into the email address field in each of the other three objects. I also want the field to update if the main email address is changed. I have shown a brief overview below;

Custom Object A - My main custom object which contains the master email address field
Custom Object B - Lookup field to object A, contains an email address field
Custom Object C - Lookup field to object A, contains an email address field
Custom Object D - Lookup field to object A, contains an email address field

Email address fields within custom objects B,C,D need to be updated using the main email address field in custom Object A and continued to be updated each time the main email address changes.

Any help would be greatly appreciated.

  • 2
    Hi Chris, welcome to SFSE. What exactly is your question? Could you please post the code you have developed or any steps you have taken towards your desired result - no one is going to write an entire trigger for you, and there are plenty of samples online for this use case (very common) if you search. – Brian Mansfield Apr 28 '15 at 14:00
  • Hello Bri, Thank you. Sorry I could not see any triggers that were similar to mine when I looked. – Chris Apr 28 '15 at 14:03
  • As a start, you create a trigger on Object A that fires on update (and insert if you want - it sounds like you do). In the trigger, you use SOQL to retrieve the records of Object B, C, D that are related to the record of Object A that is firing the trigger. From there, it is straightforward to update the fields on the B, C, D records from the A record. Not to open a can of worms, but also make sure it's bulkified (capable of handling large sets of worst-case records without hitting governor limits). – Brian Mansfield Apr 28 '15 at 14:12
  • Thank you, and would a trigger fill in the email address field of the custom objects or would the field that I need to auto update need to be text based field as I need them to be email address field due to a workflow I have setup for them. – Chris Apr 28 '15 at 14:16
  • 3
    If they are child-objects, can't you use a formula field to pull the email 'down' into the child records? Maybe I'm misunderstanding the question. – HomerJ Apr 28 '15 at 14:18

You can create a formula field in the Child objects to fetch the email from Parent.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.