Find your content:

Search form

You are here

how to create a opportunity converted from lead in test class

 
Share

I am writing a test class and need to create test data on an opportunity converted from a lead.

I can create a lead in test class

Lead testLead = new Lead();
testLead.FirstName = 'Test First';
testLead.LastName = 'Test Last';
testLead.Company = 'Test Co';
insert testLead;

But not sure how to convert it to an opportunity.


Attribution to: user481

Possible Suggestion/Solution #1

This is done using the convertLead operation. It is documented at

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_convertLead.htm

If you want to do it using a trigger, refer this blog post.


Attribution to: Gaurav Kheterpal
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/1040

My Block Status

My Block Content