You need to sign in to do that
Don't have an account?

Trigger on Opportunity to create new leads
Hello all,
I need to create two new leads when an Opportunity is closed-won and map over some date from Opp to the new leads.
I am a newbie to Apex programming and any pointers how to do this is really appreciated.
Thanks much,
VK86
Is the goal to track renewals? Why not create another oppty instead?
If you go the lead route, you want to create an oppty trigger that will add the info required.
All Answers
Definitely bookmark the Apex Developer's Guide:
http://www.salesforce.com/us/developer/docs/apexcode/index.htm
I also recommend browsing the documentation start page on developer.force.com, you can learn from the examples in there:
http://wiki.developerforce.com/index.php/Documentation
Your trigger will look similar to this (not tested):
Hello ahab1372,
Thanks much for the info.
Will definitely try this out.
Thanks,
VK86
Is the goal to track renewals? Why not create another oppty instead?
If you go the lead route, you want to create an oppty trigger that will add the info required.
Oops - looks like I was slow on the draw ;)
Thanks much jkucera & ahab1372!!
I was able to successfully run the trigger.
All i want to do now is fire the 'Active Assignment Rule' (i checked it by default but still it is not getting fired)
Thanks,
VK86
you have to replace the simple "insert" call with the database method and specify DML options:
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_dml_insert.htm
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_methods_system_database_dmloptions.htm
Thanks a lot ahab1372!!!
Its working now as i wanted.
Thanks again!