I'm currently working on packaging an application using second-generation packaging in Salesforce. As part of this process, I need to include custom metadata records along with the packaged components.

Specifically, I want to store token values using custom metadata and package them so that they are available in the target org upon installation of the package.

Could someone please guide me on the best practices for including custom metadata records in a second-generation package? What steps should I follow to ensure that these records are properly packaged and deployed?

Any insights, tips, or resources on this topic would be greatly appreciated.

Thank you in advance for your help!

1 Answer 1


Create your Custom Metadata Type records in the UI, then retrieve the Custom Metadata Type. If you're using a Scratch Org, or any org with Source Tracking, you can force:source:pull those records, just as you would any other metadata. The main documentation for these "records" is found here.

Check out this existing question.

  • I need to do it for second generation generation package for that we don't have any user interface, Can you assist with that? Commented Mar 14 at 11:07
  • @chanchalkumar, I have updated the answer. Commented Mar 14 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .