I am performing a few REST calls in my lightning app. And the urls and tokens for REST calls are stored as custom metadata types and I query the values before making the REST call. I created a managed package and added these custom metadata types to the package. And installed the package to a new org. But, I think the metadata types are not installed to the new org because I cannot see those when I go to Setup -> Custom Metadata Types in the new org and also the REST calls are not working in the new org. What might have gone wrong?

EDIT: Query to get the metadata:

AppProperties__mdt result  = [SELECT Property__c FROM AppProperties__mdt WHERE Label = 'StaywellUrl' LIMIT 1];
String restUrl = result.Property__c;

1 Answer 1


Note that there are two parts to the Custom Metadata Type - there's the type itself and the Custom Metadata Type records. For what you are doing you need to make sure you have both in the package.

If they are both in the package you then need to check whether the Custom Metadata Type instances are protected or not - a protected CMT record is not visible or editable on the subscriber org, whereas an unprotected one is. (These unprotected CMT records cannot be deleted in the subscriber org.)

Note that the protected CMT records will still be seen in an SOQL query performed in managed package apex code, but not in code outside that package.

Take a look at this trailhead for more information.

  • The CMTs are all protected. Also, according to the second para of your answer, I should be able to query the data, right? So, why the REST calls are not working? Commented Oct 13, 2020 at 10:41
  • Are the queries applied in the package's own code?
    – Phil W
    Commented Oct 13, 2020 at 10:55
  • Yes. All the queries are called in the package's own code. I have edited the question to include the query. The only problem I can think of is I have not prefixed the metadata name with the org namespace. Will that might be the problem? Commented Oct 13, 2020 at 12:20
  • Don't think so - the metadata would (being part of a package) be in the package's namespace, not the org namespace anyway, and code in the package doesn't need to include the namespace as this is handled automatically.
    – Phil W
    Commented Oct 13, 2020 at 12:53
  • 1
    I solved it. This is my first time working with custom metadata types. Turns out, I only added the custom metadata type to the package. I didn't add the custom metadata records. After adding those, the problem is fixed. Anyway, thanks very much for your help. Commented Oct 13, 2020 at 14:39

You must log in to answer this question.

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