I have custom button on Opportunity.On click of button I need to pre populate values on contract with values from oppty.Once Contract is saved I need to populate Contract lookup on Oppty with the newly created contract Id.Is there any other way other than overriding button with visual force/controller.what is the best approach for this ?

  • look at ajax toolkit.
    – Rao
    Commented Apr 18, 2014 at 21:10
  • @rao can you post some example which will pre populate and on save populate the field with new created record id.
    – sfdc
    Commented Apr 18, 2014 at 21:14

1 Answer 1


URL Hacking is only going to help with populating values on the newly created record, it's not capable of updating related records.

You're only real option for this is to use a trigger that updates the lookup on the opportunity whenever the contract is created.

As an aside, you might take this a step back and see if you really need that extra lookup. The contract details are already available as a child relationship to the opportunity and chances are good that you whatever you need that lookup from the opportunity to the contract for could be accomplished with alternate methods (please ask as a separate question).

  • How do I get the opportunity ID in the trigger.
    – sfdc
    Commented Apr 21, 2014 at 15:46
  • @sf.dev if you're new to triggers, start with a tutorial (google "Salesforce trigger tutorial), e.g. Writing Your First Trigger. If you're getting stuck, please post a specific issue as a separate question. Commented Apr 22, 2014 at 16:34

You must log in to answer this question.

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