6

Is there a way to insert/load a converted lead?

I have tried creating one in apex, but got some errors.

Attempt 1:

Lead l = new Lead();
l.isConverted = true;
insert l;

Result:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Converted Account empty for a Converted Lead.: [ConvertedAccountId]

Attempt 2:

Lead l = new Lead();
l.isConverted = true;
l.convertedAccountId = '0019E00000aQ3ff';
insert l;

Result:

Field is not writeable: Lead.ConvertedAccountId

  • Wondering if that's even possible, have only seen it converted after creation. – Raul Mar 8 '18 at 10:07
  • @RahulSharma that's exactly my question :) "Is there a way to insert/load a converted lead?" – Novarg Mar 8 '18 at 10:07
  • No, there isn't. – Jovabe Mar 8 '18 at 10:20
4

Did you try by enabling "Set Audit Fields upon Record Creation" permission?

Here is how to: https://help.salesforce.com/articleView?id=Enabling-Create-Audit-Fields-for-Professional-Edition&type=1&language=en_US

Before proceeding:

An Administrator will need to enable the 'Set Audit Fields upon Record Creation' From Setup, enter User Interface in the Quick Find box, then select User Interface.

Create a Permission Set

  1. Go to Setup | Manage Users | Permission Sets.
  2. Click New.
  3. Enter Permission Set information such as 'Label' and 'Description'.
  4. Specify 'User license' for the user who will use it.
  5. Click Save.
  6. On the next page, Go to System Permissions.
  7. Click Edit.
  8. Find 'Set Audit Fields upon Record Creation' and check the box for it.
  9. Click Save.

And finally assign the Permission Set

4

There are indeed a way to import converted Lead(which is a type of creating converted lead.)

Fields we need for importing converted leads are “ISCONVERTED” , “CONVERTEDCONTACTID” , “CONVERTEDOPPORTUNITYID” and “CONVERTEDACCOUNTID“.

Step 1 : As above fields are not editable, we have to contact Salesforce Support to enable Audit fields. Enabling Audit fields means we can edit few Readonly fields like created date and above lead fields.

Step 2 : Import Account, Contact and Opportunity from Legacy system to Salesforce.

Step 3 : If you imported account, contact and opportunity in Step 2, Salesforce automatically generates Unique ID. We need that unique Id to insert Converted Lead. So Export Account, Contact and Opportunity, which is inserted in Step 2 from legacy System.

Step 4 : Create CSV File with All lead information with ISCONVERTED=TRUE and CONVERTEDCONTACTID, CONVERTEDOPPORTUNITYID, CONVERTEDACCOUNTID. CONVERTEDCONTACTID, CONVERTEDOPPORTUNITYID and CONVERTEDACCOUNTID should correspond to Ids generated by Salesforce for Contact, Opportunity and Account which will be related to converted lead.

Step 5 : Once CSV is properly created with all required Data, Insert it using DataLoader.

Note : We cannot convert existing lead using this process. Leads must be inserted with these four fields. If you try to update lead it will not give you option to edit above fields.

How do you import Converted Lead into Salesforce from Legacy System ?

2

The converted account,contact and opportunity id's are not editable. you can see the standard fields and their properties here

you might want to create the leads first unconverted and do the conversion afterwards.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.