I am clear on the fact that converted Lead records cannot be updated. This probably makes sense to somebody...
Is there a way to allow the population of lookup fields that refer to converted Leads?
To ease reporting - I have created a trigger that populates a lookup in the reverse direction from Created Account back to the Lead that it originated from.
This allows me to run a report on Opportunities and then look up to the Account and in turn identify the Lead that started it all - My client does not convert Leads to Opportunities.
The client wants to determine which leads have the best performance, i.e. do Bob's Leads generate more revenue at the end of the day than Jane's do?
My trigger is working fine, so my next step was to run the code that this trigger calls in a batch to update all of the Accounts that have already been created.
Lo and behold - Cannot Reference Converted Lead!
Now I know that there is no way to update converted Leads - but is there a workaround to allow the population of lookup fields that refer to converted Leads?
Here is a code snippet that raises the error:
Account acct = new Account(Id = '001V00000xxx'); //Account from Converted Lead
String Leadld = '00QV000000xxx'; //Converted Lead
acct.Sourced_From_Lead__c = Leadld; //Set Lookup to Converted Lead
update acct;
The Exact error message is:
System.DmlException: Update failed. First exception on row 0 with id 001V000000ECxx5; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: []
ID LeadId
instead ofstring LeadId
?