Support for External IDs when loading test data using the Test.loadData() method - Ideas - Salesforce Trailblazer Community
Trailblazer Community

All Ideas

Idea Details

Post an Idea
480  Points
Idea has been posted. Give it an upvote or downvote.

Support for External IDs when loading test data using the Test.loadData() method

Accounts & Contacts

The Test.loadData() method would be a great method to utilize to get rid of test setup code in our package. However, we have many objects that are related to each other through lookups and master-detail fields.

Test.loadData() does not support specifying an External Id when loading test data. This makes this method less than ideal for us. The solution posted at provides an example that assigns lookups through code. We want to eliminate code, not write more code.

In addition, loading test data through the Test.loadData() method when there is a required Master-Detail lookup on an object is impossible, as that field is required and there's no way to set it.

Potential Solution: Allow us to specify an External Id column in the CSV file.

Example: Say we have a custom "Order__c" object with a Master-Detail lookup to an Account. The CSV files would look something like this:

Order__c CSV File:

Account CSV File:
00058,ABC Corporation

Merge Idea · Flag

  • Upvotes
  • Downvotes



from AppExchange


No results found.

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.