0

I have a master object - Employee and its child object - training. The training has below fields:

Name
employee - reference to master

I am using data loader to insert the records in training object. The csv has columns name as Name - course1 and employee- Mark. I do not have ID of mark in csv file. This a specific scenario. I have to query Mark's(employee) Id and populate it in the employee field on training so that the record can be saved.

Is there a way to do this? is it possible to do this before insert trigger that I can query the employee id based on the name given. Any suggestions? I do not have option to pull the id in csv file.

  • So, just a clarification. You have a file which has a name of the training and employee name, but since the file only has a name, you are unable to insert in to Salesforce. Right? – Karthikeya Pammi Aug 30 '16 at 21:04
  • I guess right, let me re-phrase it , I am unable to insert because instead of Id of the employee in csv I have the name of employee only. – SfdcBat Aug 30 '16 at 21:08
1

If this is a one-time effort, first download the employees object into a CSV, then do an excel VLOOKUP to populate the original CSV with the employeeId and then do a regular data load.

If this is ongoing, you can look into creating an externalID field in the employee object that contains some piece of unique data (I wouldn't recommend using the name, but it is not impossible). Then use that externalID to perform an upsert of the training table. Data Loader will let you link to the employee object by the external id.

| improve this answer | |
  • I am using a dataloader CLI and auto mated the process of loading CSV. The person who generates the CSV does not want to do VLOOKUP for this and just want to keep the CSV file as it is. Though the CSV file has a reference to an external ID - employee id , which is a external id in both employee and training data – SfdcBat Aug 30 '16 at 21:20
  • If you have an externalId in the Employee object and that datapoint in the CSV, then you don't need anything else. I recommend you do it one-time through the dataloader GUI to learn the syntax you need to pass the CLI. – Sebastian Kessel Aug 30 '16 at 21:21
  • Can you let me how would I populate the employee field(lookup field) on training object if I have an external id ? Do I have query it ? – SfdcBat Aug 30 '16 at 21:22
  • I mean I would have to do the mapping of fields before upsert correct? – SfdcBat Aug 30 '16 at 21:24
  • 1
    No worries. I think the info you gave on external id was helpful and my solution should be based on that. I will take care. Thanks – SfdcBat Aug 30 '16 at 22:04

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.