My task is to create an LWC component and then add it to a managed package. I was told that to store the API and the key to it, you should use Custom Settings and Custom Metadata Types. No more specifics. Since I'm new, I assumed that the API should be stored in Custom Settings, and the key in Custom Metadata Types.

I added a new entry in Custom Settings: enter image description here

Next, I try to add a new field and get an error. I understand that this is not how I write the path to my Custom Metadata Types record? Here is my formula:

"the_api_is_specified_here" + $CustomMetadata.Weather_api_key__mdt.key__c

enter image description here

In here is my Custom Metadata Types record (which I am trying to refer to at the end of the formula):

enter image description here enter image description here

Maybe I'm wrong and I need to implement it in a different way?

  • Something does not seem to match up. You separately show $CustomMetadata.Weather_api_key__mdt.key__c as part of your formula, but the error shown in your screenshot seems to indicate that you have $CustomMetadata.Type__mdt.Weather_api_key.key__c in your formula. Could you please clarify?
    – Moonpie
    Apr 28, 2021 at 15:12

1 Answer 1


You are mixing CustomSettings and CustomMetadataType in your setup. It looks as if you wish to use CustomMetadataType and I recommend that.

Your formula to retrieve the key__c from Weather_api_key (CustomMetadataType) should be:


Your formula to retrieve the key__c from weatherAPI__c (CustomSetting) should be:

  • I was confused and thought the same thing at first, but I believe the OP might be trying to reference a Custom Metadata Type in a formula on a field inside of a Custom Setting.
    – Moonpie
    Apr 28, 2021 at 16:29
  • @Moonpie I updated the screenshot with the error and described the essence of the issue in more detail. Apr 28, 2021 at 17:28
  • Are you looking to use the Custom Metadata Type record as a Default Value on the new field in a Custom Setting? Formula Data Type field is not supported in Custom Setting so if you are picking this Data Type as the new field, your not creating it on a Custom Setting.
    – TSmith
    Apr 29, 2021 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.