function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RafalRafal 

Protected Custom Metadata Type records not visible in subscriber org

I am developing managed package, following documentation have created protected custom metadata type witch is used to store api keys

`Only Apex code in the same managed package can see the type. The name of the type and the record are visible if they're referenced in a formula.`

I can retrieve api key in my own org which is the same namespace as package (package has this metadata type included)

however when i install package in another org, metadata records are not visible and i can not retrieve my api key

I have looked into many examples and based what i understand it should work out of the box. what am i missing ?

in this video https://youtu.be/aqztf1nJv-k?t=1948 which the same setup it seems to work, why it is not working for me ?

VinayVinay (Salesforce Developers) 
Hi Rafal,

Can you include screenshot of same?

https://help.salesforce.com/s/articleView?id=sf.custommetadatatypes_package_access.htm&type=5

Thanks,
RafalRafal

Is that what you are after ? 

You can see on screenshots below that my custom metadata type is package protected and records are public. (the same as in the video i linked)

I tried many ways of getting the record:

ortto__Ortto_API_Credential__mdt md = ortto__Ortto_API_Credential__mdt.getInstance('ScoresAPI');

which works in my org but return null in subscriber org, or

ortto__Ortto_API_Credential__mdt[] mds = [SELECT ortto__Username__c, ortto__Password__c FROM ortto__Ortto_API_Credential__mdt WHERE DeveloperName = 'ScoresAPI'];
which as well works in my org but returns empty in subscriber org

how do i make it work ? do fields have to be public ? (it does not work if they are protected either)


User-added imageUser-added image


here you can see that this metadata is included in the package
and that there is nothing else to add when trying to add more metadata

User-added imageUser-added image

Muralidhar S (Salesforce)Muralidhar S (Salesforce)
Rafal,

Have you added the records for your metadata ortto__Ortto_API_Credential__mdt in the the package?
RafalRafal
can you specify how do i do that ? to confirm we are talking about the same stuff
RafalRafal
Please help
RafalRafal
any ideas ? anyone ?