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
NYCMeghanNYCMeghan 

Auto Create Contracts from Opportunities

First off, apologies for the fact that I am a non-developer posting in the developers forum - but I can't seem to solve this elsewhere.
 
Has anyone come up with a fix that would auto create a contract off of an opportunity?  Ideally, upon closure, but really at any stage would do.
 
We sell a subscription based product and want to take advantage of the features available with the contracts tab, but without requiring duplicative data entry.
 
I have a feeling that this could be done with Apex, but I have no idea where to start.
 
Any feedback would be most appreciated!
 
 
advlgxpmadvlgxpm
Can you do javascript if not APEX? You could probably easily add a custom button to the form that creates the contract if the opp is closed, that creates the contract record. That's a very simplistic automation, but you could get fancier from there.
RickyGRickyG
NYCMeghan -

Ah, it warms my heart to see you trying to avoid duplicating data!

Yes, this can be done with Apex.  You would create a trigger which would fire after insert and update, create a list of contract records, add a record and set the values, and then do an insert.  Of course, you could easily add a selection condition to only do this once the status changed to closed. 

Let me know if you need some example code.  You are probably best off getting the new Developer's Guide to the Force.com Platform here.

Hope this helps.