+ Start a Discussion
BARBAR 

Custom Object --- Master/Detail relationship --- trigger help needed

I created a custom object - "Sponsorship".   Either an individual Contact or an Organization/Account may be a "sponsor", so I created the master/detail relationship from Organization/Account --> Sponsorship (since an account record exists for each Contact as well as for each Organization).

 

I created an After Insert trigger on Sponsorship to automatically create Donation/Opportunity records.  This works great when a new Sponsorship record is added from the Organization/Account tab, but does not work from the Contacts tab.

 

How do I modify the trigger to use the Id from the Contact record when creating the new Donation/Opportunity records and use the Id from the Organization/Account record when adding from that interface?