Custom Metadata Type in Salesforce: The Salesforce Developer Community was limited to creating metadata for Salesforce-provided objects before the Summer ’15 release. The only means to configure apps were through Salesforce’s pre-packaged solutions, which included building an Apex class, adding custom fields to one of the standard objects, or making a completely new custom object.
Since custom metadata types have been introduced, administrators and developers can now design, deploy, and update their own configuration and application metadata within the custom metadata types as needed.
Within Salesforce, establishing custom objects or custom settings is comparable to establishing custom metadata types. A custom metadata type’s records are metadata in and of itself, not data. During deployment, Custom Metadata Type and its records can be moved from one organization to another. However, only Custom Settings’ metadata can be carried. Custom Metadata types are typically upgradeable, deployable, packageable, and customizable.
Table of Contents
ToggleHow to Make a Custom Metadata Type
Salesforce suggests this feature for the following use cases:
- Mappings: Establish connections between various items, like unique information types that designate provinces, states, or cities to specific areas of a nation.
- Business Rules: Integrate custom functionality with configuration records. Custom information types can be used in conjunction with Apex code to direct payments to the appropriate endpoint.
- Master Data: new charges, such as duties and VAT rates, can be defined by creating a new metadata type. Subscriber organs can access the master data if you include this type in an extension package.
- Allowlists: Organize lists, like those with pre-approved businesses and funders.
- Secrets: Within a package, keep data (such as API keys) in your protected custom metadata types.
The process of creating a Custom Metadata Type
Selecting “New Custom Metadata Type” under Setup > Custom Metadata Types. As with a standard custom object, you must provide a label, name, and description for your Custom Metadata Type.
Step 1: Look for “Custom Metadata Types” under Setup first. As indicated below, click “New Custom Metadata Type.”
Step 2: Complete the appropriate fields, such as the API name and label. Selecting a data type for your records is another requirement. Checkbox, date, email, number, percent, picklist, and text are among the possible data kinds.
Step 3: Create custom fields as indicated below, and click the “New” button. After completing the Labels, save.
Step 4: You can start producing records for it after creating the fields. Click “new” after selecting the “Manage Metadata Name” button to achieve this.
Step 5: Fill out the record’s fields. The data type that you selected while creating the Custom Metadata Type will determine the fields. For instance, if you choose “text,” you can enter text values in your fields.
Benefits of Salesforce’s Custom Metadata Types
Modular data model: You can specify a data model with Custom Metadata Types that are specific to your application’s requirements. You can construct fields tailored to your use case and develop relationships between records in this way. Your application may then be more adaptable and more tailored to your requirements.
Data that changes: Custom Metadata Types can be modified without requiring code modifications or recompiling, in contrast to Custom Objects. As a result, you can update data quickly and without going through the entire development process.
Simple to administer: Creating, editing, and deleting records is made simple for administrators by the ability to manage Custom Metadata Types using the Salesforce Setup interface. Furthermore, you can verify the accuracy and timeliness of your Custom Metadata Type data using Salesforce’s built-in capabilities.
Improved scalability: For more extensive data sets, Custom Metadata Types offer improved scalability. The data is not counted against the governor restrictions that apply to other types of Salesforce data since it is stored in the metadata layer of Salesforce.
Simple to implement: Integrating Custom Metadata Types into various Salesforce organizations is a straightforward process.
Integration with Apex code: Apex code provides easy access to Custom Metadata Types, which facilitates seamless integration with other Salesforce functionalities.
Rules for Validating Custom Metadata Types
Before a user can save a record, validation rules ensure that the data they submit satisfies the requirements you set forth. A formula or phrase that assesses the data in one or more fields and yields a value of “True” or “False” can be found in a validation rule. When a validation rule returns a value of “True” because a value is invalid, the user will additionally see an error message.
Particular Type Fields for Metadata and Validation Rules: Relationship fields are among the fields of custom metadata types where validation rules can be used. Remember these pointers while you work.
Particular Types of Metadata and Formulas for Validation Rules: To hold the values of validation rule entries, use custom metadata records. Then, avoid adding the same values to many validation rules by referencing the records directly within the rules. Making use of packaging? You can specify the reasoning and let a subscriber do the customization.
Custom Metadata Types: What Are They?
Application metadata that can be customized, deployed, packaged, and upgraded is known as custom metadata. To determine the format of the application metadata, you must first establish a new metadata type. Next, you construct reusable functionality that uses that kind of metadata to determine behaviour.
You or others can declaratively construct custom metadata records that are defined by a public custom metadata type once it has been created. Customers who install the package can contribute their entries to a general custom metadata type that you package.
Your reusable functionality generates unique application behaviour by reading your custom information. For specific use scenarios, for instance, you can use custom metadata types.
- Maps: Establish connections between various items, like a personalized metadata category designating cities, states, or provinces to specific areas within a nation.
- Business rules: Integrate custom functionality with configuration records. For the purpose of routing payments to the appropriate endpoint, use custom information types and Apex code.
- Primary data: Assume you utilize a typical accounting application. Establish a unique metadata type that specifies outstanding fees like taxes and VAT rates. Subscriber organs may make use of this primary data if you offer it in an extension package.
- Allowlists: Keep track of lists, like those with preapproved merchants and donors.
- Secrets: Preserve data in your protected custom metadata types inside of a package, including API keys.
Custom metadata rows have a structure similar to that of custom object rows. Custom metadata rows can be added, edited, and removed via the Metadata API or Setup. The records are metadata; thus, you can utilize packages or Metadata API tools to transfer them.
Advantages of Custom Metadata Types
Now that you have a clear understanding of how custom metadata types may be used and managed let’s go over some benefits associated with putting this functionality to use.
Accommodates Complex Data Types: As I already indicated, and I can’t emphasize enough how important this feature is, you can construct fields to store your data directly on the custom metadata type, so you can go as straightforward or as complicated as you’d want. Users can access the records when necessary, but administrators can control them.
You can construct the following types of fields:
- Relationship Metadata Checkbox
- Date and Time/Date
- Phone Number and Email Address Picklist
- Copy & Paste Area URL
Conclusion
Finally, Salesforce’s Custom Metadata Types prove to be a game-changer by providing a solid solution for dynamic business rules, configuration management, and global application scalability. Organizations may improve their development processes, foster agility, and create apps that adapt quickly to changing business needs by grasping the subtleties of Custom Metadata Types.
The thoughtful application of Custom Metadata Types will undoubtedly continue to be a pillar for creative and flexible Salesforce solutions as the platform develops.