You need to sign in to do that
Don't have an account?
Lavanya Ponniah 3
This is my trigger it shows
trigger LeadConvert on Lead (before update)
{
for(Lead l : Trigger.New)
{
if (trigger.old[0].isConverted == false && trigger.new[0].isConverted == true)
{
if (Trigger.new[0].ConvertedContactId != null)
{
Contact contCk = [Select Id, Name From Contact Where Id =: l.ConvertedContactId];
contCk.LastName = l.Name;
update contCk;
}
if (Trigger.new[1].ConvertedContactId != null)
{
Contact contCk = [Select Id, Name From Contact Where Id =: l.ConvertedContactId];
contCk.LastName = l.Name;
update contCk;
}
if (Trigger.new[2].ConvertedContactId != null)
{
Contact contCk = [Select Id, Name From Contact Where Id =: l.ConvertedContactId];
contCk.LastName = l.Name;
update contCk;
}
if (Trigger.new[3].ConvertedContactId != null)
{
Contact contCk = [Select Id, Name From Contact Where Id =: l.ConvertedContactId];
contCk.LastName = l.Name;
update contCk;
}
if (Trigger.new[4].ConvertedContactId != null)
{
Contact contCk = [Select Id, Name From Contact Where Id =: l.ConvertedContactId];
contCk.LastName = l.Name;
update contCk;
}
if (Trigger.new[0].ConvertedAccountId != null)
{
Account accCk = [Select Id, Name From Account Where Id =: l.ConvertedAccountId];
accCk.Name = l.Name;
update accCk;
}
if (Trigger.new[0].ConvertedOpportunityId != null)
{
Opportunity oppCk = [Select Id, Name From Opportunity Where Id =: l.ConvertedOpportunityId];
oppCk.Name = l.Name;
update oppCk;
}
}
}
}
This shows
Error: System.DmlException: Update failed. First exception on row 0 with id 00Q9000000TNp8GEAT; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadConvert: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 003900000158pD8AAI; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Last Name]: [Last Name] Trigger.LeadConvert: line 12, column 1: [] (System Code)
{
for(Lead l : Trigger.New)
{
if (trigger.old[0].isConverted == false && trigger.new[0].isConverted == true)
{
if (Trigger.new[0].ConvertedContactId != null)
{
Contact contCk = [Select Id, Name From Contact Where Id =: l.ConvertedContactId];
contCk.LastName = l.Name;
update contCk;
}
if (Trigger.new[1].ConvertedContactId != null)
{
Contact contCk = [Select Id, Name From Contact Where Id =: l.ConvertedContactId];
contCk.LastName = l.Name;
update contCk;
}
if (Trigger.new[2].ConvertedContactId != null)
{
Contact contCk = [Select Id, Name From Contact Where Id =: l.ConvertedContactId];
contCk.LastName = l.Name;
update contCk;
}
if (Trigger.new[3].ConvertedContactId != null)
{
Contact contCk = [Select Id, Name From Contact Where Id =: l.ConvertedContactId];
contCk.LastName = l.Name;
update contCk;
}
if (Trigger.new[4].ConvertedContactId != null)
{
Contact contCk = [Select Id, Name From Contact Where Id =: l.ConvertedContactId];
contCk.LastName = l.Name;
update contCk;
}
if (Trigger.new[0].ConvertedAccountId != null)
{
Account accCk = [Select Id, Name From Account Where Id =: l.ConvertedAccountId];
accCk.Name = l.Name;
update accCk;
}
if (Trigger.new[0].ConvertedOpportunityId != null)
{
Opportunity oppCk = [Select Id, Name From Opportunity Where Id =: l.ConvertedOpportunityId];
oppCk.Name = l.Name;
update oppCk;
}
}
}
}
This shows
Error: System.DmlException: Update failed. First exception on row 0 with id 00Q9000000TNp8GEAT; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadConvert: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 003900000158pD8AAI; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Last Name]: [Last Name] Trigger.LeadConvert: line 12, column 1: [] (System Code)
It looks like the last name of converted contact is gettng null. This could happen in another trigget. Please check in debug logs to identify where it getting nullified.
Regards,
Sravs
That said, line 12 is the first time that you try to update a contact. The fact that the LastName required field is missing implies that l.name is null, though I can't see how that would happen unless that somehow gets blanked for a converted lead. I'd try putting some debug into the trigger to output the exacts state of the contact, for example: