Salesforce Configuration Notes
1. Custom Metadata Types (CMDT)
Purpose: Store deployable configuration data used by applications.
Why Used:
- Avoid hardcoding values in Apex.
- Configuration can be deployed between environments.
- Faster access and cached by Salesforce.
Creation Steps:
1. Setup → Custom Metadata Types → New
2. Define fields
3. Create records using Manage Records
Example Apex:
Loan_Config__mdt config = Loan_Config__mdt.getInstance('HomeLoan');
Decimal rate = config.Interest_Rate__c;
Real Example:
Store loan interest rates for Home Loan, Car Loan, Education Loan.
Admins can change values without modifying code.
2. Custom Settings
Purpose: Store frequently accessed configuration data.
Types:
1. List Custom Settings – Multiple configuration records.
2. Hierarchy Custom Settings – Values based on User, Profile, or Organization.
Advantages:
- Cached for faster access.
- Can be accessed without SOQL.
Example Apex:
Withdrawal_Config__c config = Withdrawal_Config__c.getOrgDefaults();
Decimal limit = config.Daily_Limit__c;
Real Example:
Store daily withdrawal limits or tax percentages.
Note: Salesforce now recommends Custom Metadata instead.
3. Custom Labels
Purpose: Store reusable text values for UI messages and multi-language support.
Why Used:
- Avoid hardcoding UI text.
- Reusable across Apex, LWC, Validation Rules.
- Supports translations.
Creation:
Setup → Custom Labels → New Custom Label
Apex Example:
String message = Label.Welcome_Message;
LWC Example:
import welcomeMessage from salesforce label module.
Use Cases:
- Error messages
- Welcome messages
- Button labels
4. Static Resources
Purpose: Store files used in the Salesforce UI.
Examples:
- Images
- CSS files
- JavaScript libraries
- Fonts or PDFs
Creation:
Setup → Static Resources → Upload file
LWC Example:
Import resource URL and use in component.
Real Use Case:
Store bank logos, chart libraries, or CSS frameworks for UI.
5. Comparison Overview
Custom Labels → Text values used in UI
Custom Settings → Configuration data
Custom Metadata → Deployable configuration
Static Resources → Files such as images or libraries
Typical Architecture:
Custom Metadata → Business configuration
Custom Labels → UI text messages
Static Resources → UI assets
6. Example Bank Project Usage
Custom Metadata:
Interest rates for different loan types.
Custom Settings:
Daily withdrawal limit configuration.
Custom Labels:
Messages such as Welcome to Bank Portal or Transaction limit exceeded.
Static Resources:
Bank logos, CSS styling, JavaScript libraries.
7. Important Interview Points
- Custom Metadata records can be deployed across environments.
- Custom Labels support multilingual translation.
- Static Resources store UI assets.
- Salesforce recommends Custom Metadata instead of Custom Settings for most configurations.