문제

I am getting an error message when I try to instert a custom object into an exisiting lead object.

List<Lead> leads =[select Id from Lead where Email =:lead.Email ];
if(leads.size()>0)
{
    Lead existing_lead = new Lead(Id = leads[0].id);
    social_account.Lead__c = existing_lead.Id; //social_account is a custom object that
                                               //has a child relationship to lead.
                                               //ie lead is a parent of social_accounts.
    update existing_lead;
    insert social_account; //if there is an existing lead with same same email,
                           //i'd like to insert new social_account to an exsiting lead.
}

I am getting this error:


554 System.DmlException: Update failed. First exception on row 0 with id 00Q3000000WW3isEAD; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: []

Class.ProcessContact.handleInboundEmail: line 81, column 9 External entry point


even if I comment out the 'update existing_lead', i get a similar error message.


554 System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: [Lead__c]

Class.ProcessContact.handleInboundEmail: line 82, column 9 External entry point


I would appreciate any suggestions.

regards

도움이 되었습니까?

해결책

This error means that the Lead record has been converted to a Contact. Once converted, the Lead record cannot be updated. The Lead object has an IsConverted property that you can check to see if it has been converted. If IsConverted is true, ConvertedContactId will hold the contact ID of the new Contact record.

Lead Object reference

다른 팁

You cannot update converted Lead by default, but after Sprint 16 release, there is possibility, just you need to setup few things.

-From Setup, enter User Interface in the Quick Find box, then select User Interface then select Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions.

-From Setup, enter Profiles in the Quick Find box, then select Profiles. Select the profile and then select Set Audit Fields upon Record Creation.

Here you can find more information's about this.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top