function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
smatharusmatharu 

Apex Data Loader - external ID instead of OwnerID

Hi all,

 

I'm trying to load data into my custom object using the command line data loader, but am stuck trying to load the OwnerID using my External ID on teh User object.

 

I've got 2 users with external id field = Dataload_Id__c, and values = "owner_1", "owner_2"

Many of my data files will be wanting to assign ownership to one of these users (and potentially others), but I can't figure out the external ID syntax for my SDL file in data loader.

 

I've tried the following:

 

 

OwnerId=Owner\:Dataload_id__c

OwnerId=User\:Dataload_Id__c

OwnerId=Owner\:User\:Dataload_Id_c

 

none are working.

 

I know I can put the exact salesforce ID of my owners in the csv file, but this file will be used on numerous sandboxes where the owners will be created manually and repeatedly, meaning the salesforce ID won't be consistent. Also, files will be arriving from multiple sources, where creators only know the external ID of the owning users.

 

I'm sure this can be done, as I've used third party tools like Pervasive Data Integrator which allowed me to put, for example, "(User:Dataload_Id__c:owner_1)" as my load value. Pervasive used the standard salesforce API.

Thing is, I don't know how to translate this to an SDL file.

 

Can anyone help?

 

 

Kind regards,

Sunny

smatharusmatharu

Hi guys,

 

I've had to implement a workaround using a little Java app that replaces placeholders I've put into the ownerid column. This isn't proving to be optimal because I need copies of my csv files that just act as templates, and also because I'm using the Java app to insert the exact salesforce ID of the record owner into my CSV.

 

Is there no way this can work using external ids on the User object?

CalifemCalifem

Havin the same issue here. I am able to map the Owner field of an object to User.external_id__c in the Workbench, but none of the following worked within a .sdl file and the data loader:

csv_column_name=Owner__r\:external_id__c

csv_column_name=OwnerId__r\:external_id__c

csv_column_name=Owner.external_id__c

 

Anyone managed to work this out?

StefgStefg

I am also having this problem and it is causing me a lot of hassle as I am working on an automated load of data for a testing process. Everything is working fine except for the owner. Has anyone figured out how to set the Owner by using an external Id on the User record?

StefgStefg

I have found that external Id will work for standard object upserts e.g. Opportunity, but it does not work on custom objects.  So I can update the Owner of an Opportunity with the following in the .sdl file:

 

OWNERID=Owner\:ExternalID__c

  

But if I do the same for a custom object, it does not work and I get the following error:

 

com.salesforce.dataloader.exception.MappingInitializationException: Field mapping is invalid: OWNERID => Owner:ExternalID__c
	at com.salesforce.dataloader.mapping.LoadMapper.resolveMappedFieldsForDataLoad(LoadMapper.java:85)
	at com.salesforce.dataloader.action.AbstractLoadAction.initOperation(AbstractLoadAction.java:92)
	at com.salesforce.dataloader.action.AbstractAction.execute(AbstractAction.java:117)
	at com.salesforce.dataloader.controller.Controller.executeAction(Controller.java:120)
	at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:149)
	at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:100)
	at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:253)

If I use the GUI of the dataloader to upsert and I get the option to select an external id for the Owner for the standard object but not for custom objects.  Does anyone know how to acheive this?

StefgStefg

After some further investigation I think I have found the problem.  On the standard objects like the Opportunity the Owner field is a Lookup(User) but on custom objects the Owner field is Lookup(User,Queue).  I assume that because the lookup is for multiple objects, an external id lookup cannot be use, which is unfortunate.

 

There is a related discussion here

 

It doesn't look like there is a simple solution unfortunately.

tfendttfendt
@Stefg

You say you can get it to work with standard objects. I am using the accounts object and the user object. Both are standard objects but I get the same error you do when you use the custom objects. How did you get it to work or standard objects?
tfendttfendt
I got it to work. The issue was the user that was doing the upsert count not see the external id field within dataloader. Once access was given to that user the mapping worked.