How can I set externalId for the object without exporting its records?

Question.


How do I define, which column is used to do a lookup to a different external id?

When I have a query that does a lookup to the Contact object to get the contact ids, it by default uses the Name column to do the lookup.
However the standard Name is not a queryable field on several objects.

Sample Query: SELECT Id, Name, Contact__c FROM Contact_Method__c

.. [16:07:28.321] Getting metadata for Contact (SOURCE) [16:07:30.190] Getting metadata for Contact (TARGET) [16:07:33.441] The parent sobject Contact for the lookup field Contact_Method__c.Contact__c has been included into the process. The externalId is set to 'Name'. ..

.. SELECT Id, Name FROM Contact WHERE Name IN ('Test User1', 'Test User2' ^ ERROR at Row:1:Column:36 field 'Name' can not be filtered in a query call. [16:08:16.583] Execution of the command sfdmu:run has been finished. Exit code 4 (COMMAND_EXECUTION_ERROR). ...

Answer.


If you just want to set the externalId for the Contact object, you need to include Contact object in your export.json with "operation": "Readonly", then set the externalId for the Contact to another field than Name.

This will avoid exporting Contact records but will change it's default externalId field from Name to the desired value.


See also:

Full export.json format

Last updated on Tu May 2022