• Ramkumar R
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hey Team,

I've been countering a strange issue--currently I'm working with support to try to figure it out, but we're hitting walls. 

I'll give the quick version first, and then more details below if you need it.

I have a super simple process builder: When a lead is converted, update a field on the contact it's converted into. However, I'm getting the error above.

---

Details:

First off, every solution built in webdev seems to work; however, it does not work in product. We've done a sandbox refresh just in case, but the process still works in webdev, but not production.

I've narrowed things down as far as I can, and I think I've come to this root cause:

It's specifically the lead conversion. For instance, I decided to bypass the process builder and build out what I'm trying to do in a flow, so I can test some more. You'll see the image attached that the update process fails. All the update process does is reference the converted contact ID (pass through Process builder) to update that contact's field.

It fails--super simple, though. You can even see in the log that it does capture the ID. 

So, I decided to use the debug method in Flow and hardcode that ID into it, and the process works just fine. Which leads me to believe that the issue is with the ID being passed through the lead conversion.

But I can't think about what the issue may be in this instance.

Has anyone ever encountered this error before and has some experience troubleshooting it?

(Also, the PB is simply: When lead is created or edited; is it converted?; launch flow. While testing, I don't have any other Lead related PBs active).

Thanks,
Nick

User-added image
Hi all,

The Lead object has some custom fields and when it's converting to a Contact I have to set the values of these fields to the custom fields of the Contact.

There are two options 1 - a new Contact and 2 - the already existing Contact.

For the second option I need to set the values only if they were not set previously (do not overwrite the previously set values)

I've created the Trigger:

trigger AACopyLeadFields on Lead (after update) {
Map<Id,Lead> leadStatus = new Map<Id,Lead>(); // Map of the converted Contact ID and the Lead Status

for(Lead lead : Trigger.new) {
if (lead.IsConverted) {
leadStatus.put(lead.ConvertedContactId,lead);
}
}

List<Contact> conContacts = new List<Contact>();

for ( Contact c : [select Id, LeadSource, CreatedDate, Converted_from_Lead__c from Contact WHERE Contact.Id IN :leadStatus.keySet()]) {
Lead lead = leadStatus.get(c.Id);
if(c.Converted_from_Lead__c == null) {
c.LeadSource = lead.LeadSource;
c.Lead_Source_Ext__c = lead.Lead_Source_Ext__c;
c.FirmwareEmail__c = lead.FirmwareEmail__c;
c.NewsletterEmail__c = lead.NewsletterEmail__c;
c.SoftwareEmail__c = lead.SoftwareEmail__c;
c.TrainingEventsEmail__c = lead.TrainingEventsEmail__c;
c.Converter_from_Lead__c = lead.Id;
conContacts.add(c);
}
}

if(conContacts.size() > 0) update conContacts;
}

When I convert a Lead into a new Contact (contact.CreatedDate == lead.LastModifiedDate) it works fine, but when I convert a Lead into already existed Contact it shows the error:

"
There was an error converting the lead. Please resolve the following error and try again: AACopyLeadFields: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0037F00001BJtnnQAD; first error: UNKNOWN_EXCEPTION, java.lang.NullPointerException: [] Trigger.AACopyLeadFields: line 27, column 1
"

There is no any issue in the Partial Copy Sandbox.

Did someone have the same issue?



Thank you.

Regards, Michael Novozhilov
 
even also i am using readonly  atribute ,  geting same error please do the needful,

Collection size 10,028 exceeds maximum size of 10,000. 


<apex:page controller="Leaddisplay" readOnly="true">

       <apex:pageBlock >
           <apex:DataTable value="{!ld}" var="a">
               <apex:column value="{!a.Lastname}"  headerValue="LastName"/>
            <apex:column value="{!a.company}"  headerValue="companyName"/>
               <apex:column value="{!a.status}"  headerValue="LeadStatus"/>
                     <apex:column value="{!a.phone}"  headerValue="phone"/>
               </apex:DataTable>
             
                 </apex:pageBlock>
      </apex:page>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>....


public class Leaddisplay {
    public list<lead>ld{set;get;}
    public Leaddisplay(){
       // ld= new list<lead>();
       ld=[select  lastname,phone,company,status from lead];
        
    }

}