[SalesForce] Unable to insert custom metadata records with cmdt command

I've created via the UI a custom metadata type, now I want to add records to it from a CSV using the sfdx CLI.

I tried the cmdt:record:insert command but I get the following error:

ENOENT: no such file or directory, scandir
'force-app/main/default/objects/My_Settings__mdt/fields'

Full command: sfdx force:cmdt:record:insert --filepath mdt_records.csv --typename My_Settings

(The mdt_records.csv file is saved in the project base folder, where I enter the command above)

I don't have an 'object' folder on my project, so I tried to pull the custom metadata hoping it will land in object folder but it was populated on:

force-app/main/default/customMetadata/

and not on

force-app/main/default/objects/…

Couldn't find anything useful in the documentation.

Please advise.

Best Answer

You can retrieve the MDT and fields using the CLI command

"sfdx force:source:retrieve -m CustomObject:MetaDateName__mdt"

Then use this CLI command to create the custom MDT xml files for the records that you have in the csv file

"sfdx force:cmdt:record:insert --filepath FileLocation:\FileName.csv --typename MetaDateName__mdt"