function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

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!!!!!!!

Why not use a formula field on the custom object?

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


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:{

      if (c.RecordType == TheRecTypeICareAbout){

         c.OpportunityLookup__c =;