Can Custom Metadata be mass inserted?
My Custom Metadata Type is listed as a custom object in the Data Import Wizard but when I –
- select the object
- add new records
- choose the CSV file
none of the fields are mapped and when I click Map an error’s displayed
Something has gone wrong. Cannot read property ‘length’ of undefined.
Please try again.
The Metadata Type is listed in Workbench for SOQL queries but not when I try to use it’s insert function. It’s not listed in the list of Dataloader objects.
The Data Loader, as far as I can tell, does not support Custom Metadata (and we’ve been given no indication if this will be available in the future). In fact, custom metadata isn’t “real” data, and is actually documented in the Metadata API documentation. You could choose to use Ant and build the appropriate files that way, or you can follow the other instructions for simply loading this metadata.
Summer ’20 Update
The Salesforce DX CLI can now import these records using the cmdt command. This is the recommended approach. The older tools are still technically viable, but should only be used if you somehow can’t use Salesforce DX.
In the implementation manual, the guide tells you how to import custom metadata:
Edit: The older version, included below in the original quote, has been deprecated. Please use this version instead. It also now includes a Deploy to Salesforce button to make it easier to deploy in fewer steps.
Use the custom metadata loader to bulk load records to your custom
metadata types from a .csv file. The custom metadata loader lets you
load up to 200 records with a single call.
Downloadthe tool from GitHub. Deploy the package to your org via Workbench. Note that you have to create a .zip file of the contents of
the custom_md_loader directory instead of zipping up the directory
- Create a .csv file with a header that contains the custom metadata type’s field API names. Either the Label field or the Developer Name
field is required. See sample.csv in your download for an example. If
your org is namespaced, be sure to include the namespace prefix in
- From Setup, assign the Custom Metadata Loader permission set to the appropriate users, including yourself.
- Select Custom Metadata Loader from the App Picker.
- Go to the Custom Metadata Loader tab. The app prompts you to configure your Remote Site Settings if you haven’t already done so.
- Select your .csv file and the corresponding custom metadata type.
- Click Create custom metadata to bulk load the records from the .csv file.