I need to convert a text field to Lookup field on Object 'A' As we cannot convert directly so there is one approach is to create a one object 'B'and create a lookup field on object A.My Question is if i am having lots of data in Text field(A)-Do I need to create a record in New Object(B) to display same value in lookup? or there is any other way we can achieve this ? Please suggest.

3 Answers 3


What best you can do is in your use case is create a new lookup field.

And now write a batch class and manually search for record using text field and populate your lookup with Id (This is a one time process) and delete the text field and continue using the lookup field.

  • I'd imagine that using the Data Loader would work as well.
    – Derek F
    Commented Jul 5, 2016 at 14:24
  • @DerekF but in dataloader they manually need to map records. Commented Jul 6, 2016 at 4:42
  • Are you sure about that? Going through the process in my mind, it's just extracting the current records via Data Loader, and then using Data Loader to perform an update, mapping the old text field column to the new lookup field.
    – Derek F
    Commented Jul 6, 2016 at 13:07
  • @DerekF I think Dataloader.Io can do what you suggest but other not able to do this. dataloader is a limit in free trial. Commented Jul 6, 2016 at 13:17
  • Perhaps we are talking about different tools. I have used the Salesforce-provided Data Loader (Setup -> Administration Setup -> Data Management -> Data Loader, also called Apex Data Loader) for similar tasks, multiple times in the past, over tens of thousands of records. To the best of my knowledge, this tool is provided for no additional charge, though it looks like it's only available for Developer, Enterprise, and Unlimited edition orgs (leaving out Professional and CRM Starter edition orgs).
    – Derek F
    Commented Jul 6, 2016 at 14:33

There is no need to create an entirely new object. You will need to create a new Lookup field on your object A. For purposes of illustration, I'll be referring to your existing text field as text_field__c, and the new lookup field as new_lookup__c

Assuming that your text_field__c contains a valid Salesforce Id (15 or 18 characters), you can easily take care of copying the data from text_field__c into new_lookup__c using the Salesforce Data Loader.

As a quick note, at time of writing, the Salesforce Data Loader can only be used in Developer Edition, Lightning Enterprise, and Lightning Unltimited orgs. If you're on a Lightning Professional or SalesforceIQ CRM Starter org, you'll need to find another solution.

I won't go over the basics (logging in, selecting an object, etc...), as that is covered by Salesforce's own page for their Data Loader

I have tested the following procedure myself in one of my Summmer '16 sandboxes. My org already has an object that stores an Id in a text field (been using it as a workaround for 3 years to make a pseudo-lookup to OpportunityLineItem). The general steps to take are:

  1. First, perform an export
    • Select your object A from the list of objects (Click Show all Salesforce Objects if your object is missing from the list)
    • Select the destination and name for the csv file that will be generated, click next
    • Select the Id, text_field__c, and new_lookup__c fields, then click 'Finish'
  2. Then, perform an update
    • Select your object A again
    • Browse for the csv file that was recently created, click next
    • The Data Loader will do some 'initialization'. It should succeed fairly quickly. Click Ok.
    • On step 3: Mapping, click 'Create or Edit a Map'
    • Since you only queried for 3 fields, you should only see 3 fields on the lower portion of the Mapping Dialog window. Click Auto-Match Fields to Columns. This should fill in field API names into the Name column of the lower portion of the Mapping Dialog window
    • In the lower portion of the Mapping Dialog Window, click and drag the text_field__c from the Name column so that it is on the same row as new_lookup__c. This should cause the old mapping for the row with text_field__c in the File Column Header column to disappear. This is what we want.
    • Click Ok to close the Mapping Dialog window (no need to save the mapping), then click next.
    • Choose a directory to store the success/error log files
    • Click finish, and then click yes on the warning dialog that pops up

That should be all you need to do.

Of course, the Id that you're trying to copy into the lookup field must be for the same object that the lookup field is associated with (you can't put an Id for an Opportunity into a lookup field that looks up to an Account).

The triggers, workflow, and validation rules on your object A will still run when performing operations through Data Loader. If you can't update a record in Salesforce through the web ui, then Data Loader won't be able to update it either.

Data Loader runs in batches (default batch size is 200, but this is configurable via settings). Once Data Loader hits an error in a batch, my experience is that the rest of the records in that batch will be marked with the same error. It's slower to complete, but decreasing the batch size can maximize the number of records that update successfully.

Also note that this does not delete the value from text_field__c. It's certainly possible to do this via Data Loader, it just requires a little more setup. You'd need to edit the csv file that was exported in the first major step to include a new column header (and fill all the rows with NULL, I think), change the Data Loader settings to insert null values, and then map your column with the NULLs to text_field__c instead of leaving it blank.


this is not possible to convert text field into lookup. Have you tried this? You need to create a new field of lookup type.

enter image description here

  • Yes i tried by creating new lookup and populating few data in that lookup.But what in this case if that text field contain different data for almost all records. Commented Jul 5, 2016 at 7:39
  • When you try to edit the type of field, there is no option of lookup field. Please refer the screenshot attached in answer Commented Jul 5, 2016 at 7:41
  • we need to create a same data in Lookup and needs to populate that data same as old Text Field and then we can remove that field.If any other solution please suggest Commented Jul 5, 2016 at 7:41
  • That is what I am saying.In salesforce there is no option to convert text to lookup ,But my requirement is to convert it into lookup.I am asking other approach .Thanks in advance Commented Jul 5, 2016 at 7:42
  • It is not possible and reason is in your question :). Platform got confused with existing data and not able to convert all text-field data to lookup. Salesforce not provide any functionality and you cannot do this. Commented Jul 5, 2016 at 7:52

You must log in to answer this question.

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