I'm still pretty new to APEX and wanted to see if you could help. I think its pretty straight forward.

I have a custom object called Interest which contains two custom fields. I want to update the opportunity with those fields when an Opportunity is created. There is a look-up relationship from the Interest to the Opportunity. Interest records (already have the relevant fields populated) and are automatically associated with opportunities when an opportunity is created.

All I want to do is update the opportunity fields with the fields from the interest object.

Many thanks for your help in advance!

Custom Object : Interests API Name: Interest__c

Fields on Interest Record Label Name: Core Lead ID Api Name: Core_Lead_Id__c Label Name: Core Instance ID API Name: Core_Instance_id__c

Fields on Opportunity Label Name: Core Lead ID Api Name: Core_Lead_Id__c Label Name: Core Instance ID API Name: Core_Instance_id__c

I want to populate the opportunity fields upon creation of the opportunity. Not sure it matters however users create opportunities automatically when they convert Leads to a Person Account and Opportunity. (YES I SAID PERSON ACCOUNT)

  • TobyDog - welcome to SFSE. Community etiquette is to try the task yourself and then, if you get stuck, post relevant sections of code (snippets please) and errors encountered - then you will then get help. SFSE members tend not to want to do the coding for others without demonstration of effort on your part.
    – cropredy
    Commented Mar 3, 2015 at 20:34
  • Hi there! Thanks for the tip. I will definitely do so in the future. I had attempted all the other options of formula fields and workflow rules but kind of don't know where to begin with the APEX. I am currently learning it and so will have a place to start next time!
    – TobyDog
    Commented Mar 4, 2015 at 16:18

2 Answers 2


You do not have to write trigger anymore for such processes. Just use "Process builder" or alternatively try if you work it out by simple workflow. But I am very process builder can do this.

plus you do not need apex skills.


Given your criteria it seems that there should be a one to one relationship with opportunity? If so, you may want to modify the object model to have the opportunity Lookup to the interest object then:

Since the Opportunity has a lookup to the Interest object, simply create formula fields for the required information.

If this is not possible then you will have to write a trigger or use Process Builder...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .