What is Salesforce Metadata?
Metadata is a simple lightweight language which based on XML (Extensible Markup Language).
Metadata in Salesforce describes the structure of salesforce.com and Force.com development artifacts.
Instead of the traditional development approach of code-compile-package-deploy, with Force.com you only need to code.
The magic here is that the metadata is zipped and transferred to the Force.com servers (much faster than uploading compiled code) where it is unzipped and compiled on your behalf. Not only is this super fast, but your changes are immediately available through any web browser, and there’s no downtime at all.
There are several types of Metadata, with each one representing a unique way a business function can be customized.
What is a custom metadata type?
A custom metadata type is an object that is used to define the structure for application metadata. The fields of custom metadata types, and the values in the fields, consist only of metadata.
The records of custom metadata types are also metadata, not data. Using metadata is pretty handy because it can be imported into Salesforce, modified in the interface, and manipulated using the Metadata API.
When you deploy apps with custom metadata types, all of the records and fields are included in the package installation, so no additional steps are needed. You can deploy custom metadata types from a sandbox with change sets or packaged in managed packages.
Use Cases for Custom Metadata Types
Here are some examples of what you can do with custom metadata types.
- Mappings—You can use custom metadata types to create associations between different objects. For example, you can create a custom metadata type that assigns cities, states, or provinces to particular regions in a country.
- Business rules—Salesforce has lots of ways to define business rules. One way is to combine configuration records with custom functionality. For example, you can use custom metadata types along with some Apex code to route payments to the correct endpoint.
- Master data—Say that your org uses a standard accounting app. You can create a custom metadata type that defines custom charges, like duties and VAT rates. If you include this type as part of an extension package, subscriber orgs can reference this master data.
- Protected information—Store data like API keys in a protected package.
More About Custom Metadata Types
Custom metadata types support most standard field types, including:
- Metadata Relationships
- Date and Date/Time
- Email and Phone
- Text and Text Area
For the full list of Metadata types, click here.
Developers can use SOQL to read custom metadata types. To create or update metadata records, they can use the Metadata API. Apex code can create, read, and update (but not delete) custom metadata records.
Reference Custom Metadata Types
Custom metadata types can be used directly from:
- Formula fields
- Process Builder
- Validation rules
Custom metadata types are customizable, deployable, packageable, and upgradeable application metadata. In many cases, custom metadata types have an advantage over custom settings and custom objects. They can make your application lifecycle management and compliance easier, faster, and more robust. In the next unit, you create your own custom metadata type.
- Resources: Salesforce Help: Custom Metadata Types
- For more information Salesforce Metadata: Developer Guide, click on this link to clarify your doubts.