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
durga prasad 45durga prasad 45 

lead conversion error

hi every one can any one give support when lead convert automatically geeting error. here lead owner is queue
Error:Apex trigger AutoConverter caused an unexpected exception, contact your administrator: AutoConverter: 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.: [OwnerId]: Trigger.AutoConverter: line 25, column 1
Waqar Hussain SFWaqar Hussain SF
Can you please paste you AutoConverter trigger here. 
Tarun J.Tarun J.
Hello Durga,

Seems like you have not mapped owner field in your trigger. Check your code and map owners for Account, Contact and Opportunity.

-Thanks,
TK
durga prasad 45durga prasad 45
Trigger AutoConverter on Lead (after insert,after update) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     ];
    
   
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
                 
     for (Lead lead: Trigger.new) {
          if (lead.isConverted ==false){
          if(lead.Status == 'Convert') {
               Database.LeadConvert lc = new Database.LeadConvert();
               String oppName = lead.LastName;
                           lc.setLeadId(lead.Id);
               lc.setOpportunityName(oppName);
               lc.setConvertedStatus(convertStatus.MasterLabel);
               
               leadConverts.add(lc);
          }
     }
   }
     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }
     }


Lead Owner Shoud be queue here and when login in other profile except system admin its asking required filed missing you must specify the ownerId of the user how to set owner of the id if lead owner is queue