Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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 ?

share|improve this question
    
look at ajax toolkit. –  rao Apr 18 at 21:10
    
@rao can you post some example which will pre populate and on save populate the field with new created record id. –  sf.dev Apr 18 at 21:14
add comment

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).

share|improve this answer
    
How do I get the opportunity ID in the trigger. –  sf.dev Apr 21 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. –  Ralph Apr 22 at 16:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.