You need to sign in to do that
Don't have an account?
Error: On Trigger
Hai All,
When i was entered the data and saving to Lead,Through VisualForce Page..
It Raising Error...
AutomateLeadConversion: execution of AfterUpdate caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Converted objects can only be owned by users. If the lead is not owned by a user, you must specify a user for the Owner field.: [] Trigger.AutomateLeadConversion: line 12, column 1
My Trigger :
trigger AutomateLeadConversion on Lead (After Update) {
system.debug('Enter to convert Lead');
Lead myLead = trigger.new[0];
if( mylead.Incomplete_Application__c == false && myLead.isconverted==false && myLead.SSN_Not_Eligible__c == false && myLead.No_Govt_Proof_Form__c ==false && myLead.No_Program_List__c == false){
//myLead.LeadSource == 'fax'
system.debug('Enter to convert Lead condition');
database.LeadConvert lc = new database.LeadConvert();
lc.setLeadID(myLead.ID);
lc.convertedstatus = 'Closed - Converted';
lc.setDoNotCreateOpportunity(true);
Database.LeadConvertResult lcr = Database.convertLead(lc); ---->Line 12
System.assert(lcr.isSuccess());
}
}
Please suggest me What to do for this....
Thanks,
Your code seems fine otherwise. However please check if the lead you are trying to convert is owned by a queue. If so you need to assign an owner before converting as the account and contact cannot have owner as a queue, it can only be a user.
Please check the following article point #9 in basic steps for converting leads
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_convertlead.htm
Hope this helps.
All Answers
Your code seems fine otherwise. However please check if the lead you are trying to convert is owned by a queue. If so you need to assign an owner before converting as the account and contact cannot have owner as a queue, it can only be a user.
Please check the following article point #9 in basic steps for converting leads
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_convertlead.htm
Hope this helps.
Thanks Kamal.it helped me..
I am having the same issue. Do you have a sample that I could use for the User (owner) assignment. Everything I have tried failes