Administration
Custom Metadata Types and Custom Settings Interview Questions and Answers Experienced
1. What are Custom Metadata Types in Salesforce?
Custom Metadata Types are metadata records that store application configuration and can be deployed via packages or change sets. They allow reusable, version-controlled configuration accessible in Apex, formulas, and validation rules.
2. How do Custom Metadata Types differ from Custom Settings?
Custom Metadata Types are deployable metadata and support packaging, while Custom Settings are data records. Custom Settings have caching benefits but are harder to deploy with data, whereas Custom Metadata allows config migration and can be referenced in validation rules and formulas.
3. What are the two types of Custom Settings?
List Custom Settings store static data accessible org-wide. Hierarchy Custom Settings provide personalized data based on profile or user context.
4. When should you prefer Custom Metadata Types over Custom Settings?
Use Custom Metadata Types when you need version-controlled, deployable configuration that can be referenced in formulas and validation rules. Use Custom Settings when fast cached runtime access is critical.
5. Can you query Custom Metadata records in Apex?
Yes, Custom Metadata records can be queried using SOQL just like normal objects, e.g., SELECT DeveloperName, MasterLabel FROM MyMetadata__mdt
.
6. What are Custom Labels?
Custom Labels store translatable text strings for user interface elements. They support multiple languages and help build multilingual applications.
7. How do you access Custom Labels in Apex?
Use Label.Label_Name
, for example: String labelValue = Label.My_Custom_Label;
8. How can Custom Labels be used in Lightning Web Components?
Import them in JS using: import myLabel from '@salesforce/label/c.My_Custom_Label';
then use {myLabel}
in HTML.
9. How do you deploy Custom Metadata Type records?
Via Change Sets, Managed/Unmanaged Packages, or Metadata API tools like Salesforce CLI and ANT migration tool.
10. Are Custom Settings data records deployable?
Custom Settings metadata can be deployed, but their data (records) cannot be deployed via packages or change sets; data must be loaded separately.
11. What are governor limits when accessing Custom Metadata and Custom Settings?
Custom Settings accessed via getInstance()
are cached and don’t consume SOQL limits. Custom Metadata queries count against SOQL limits.
12. Can you reference Custom Metadata Types in validation rules and formulas?
Yes, Custom Metadata Types can be referenced in validation rules and formula fields, unlike Custom Settings.
13. What is the benefit of using Hierarchy Custom Settings?
They allow you to define different values for the same setting based on user or profile, enabling personalized configuration.
14. How do you add translations to Custom Labels?
Use Translation Workbench in Setup to provide translations for each supported language.
15. Can Custom Metadata Types be protected in managed packages?
Yes, you can mark Custom Metadata Types as protected, restricting access in subscriber orgs.
16. How do you use Custom Labels in Apex?
Access Custom Labels directly via the Label
namespace. For example: String greeting = Label.Welcome_Message;
. This lets you display translatable UI text or messages.
17. How can you access Custom Metadata records in Apex?
Query Custom Metadata Types using SOQL like standard objects. For example:List
18. How do you access Custom Settings in Apex?
Use the generated Apex methods like getInstance()
for Hierarchy Custom Settings or getValues()
for List Custom Settings.
Example: MySetting__c settings = MySetting__c.getInstance();