2

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: []

5
  • You always have the Created By field, if that helps any. You could also have your Source_From_Lead__c field just be a string instead of a Lookup.
    – Mike Chale
    Jul 25, 2013 at 16:45
  • It's not that the data is not there per se, it's more a problem of the limitations in SalesForce native reporting. In order to go from Opportunity to Account to Lead, I need to make a Custom Report Type which only allows you to traverse the relationships in one direction. If I had a 3rd party reporting tool this would be a snap. I could do it with VisualForce but then the client couldn't maintain it.
    – RobD
    Jul 25, 2013 at 16:54
  • What error message do you get? Have you tried using ID LeadId instead of string LeadId?
    – Mike Chale
    Jul 25, 2013 at 16:59
  • Thanks @Mike Chale, I just tried using the ID, no joy - the code in the question is an exec anonymous snippet to avoid posting the whole unit test. I've added the exact error to the question.
    – RobD
    Jul 25, 2013 at 17:08
  • 1
    What information will the client be evaluating? If it's just a relatively few fields in the converted lead base, I'd probably use some Apex to bring that info up into the Account object for analysis. Jul 25, 2013 at 18:36

2 Answers 2

2

Converted lead in a sense is as good a 'deleted' record in recycle bin. This is not accessible for any references.

There is no way to reference converted leads

1
  • Thanks for the answer, unfortunately there is no deterministic relationship based on creators / owners. Multiple owners have multiple Leads, Accounts and Opportunities - it's all about knowing which Leads led to which Accounts
    – RobD
    Jul 25, 2013 at 17:07
1

If an object that references the lead, you can reference the lead indirectly through that object. This does not help for leads that have already been converted, but for leads that haven't been converted yet you can create a trigger that makes reference object. Just make sure users aren't able to delete the reference object, because once it is gone, it can't be recreated.

Bill

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .