+ Start a Discussion
anitha20anitha20 

Trigger for Opportunity value in custom object

Can any one tel me how to write an trigger to insert the Opportunity lookup value in the custom object ,in which object is related list for  Opportunity.Thanks in advance reply me!!!!!!!

Duncan_IdahoDuncan_Idaho
Why not use a formula field on the custom object?
anitha20anitha20

i want to do this for particular recordtype in custom object.I want the Opportunity lookup to update only for that recordr type.

kyle.tkyle.t

This is a basic framework to get you started... not sure how you are getting the opportunity ID, but hopefully this helps.

 

trigger UpdateCustomObject (before insert, before update){

 

   for(CustomObject__c c: trigger.new){

      if (c.RecordType == TheRecTypeICareAbout){

         c.OpportunityLookup__c = theOpportunity.id;

      }

   }

 

}