Salesforce allows us to migrate standard configuration records like workflow, email templates, email alerts using change set.
But If we want to deploy the custom configuration records from one org to another org using change set or want to setup the custom configuration data automatically when a managed package is installed, then how can this be achieved?
Custom Settings certainly will not be the right solution for this, because custom settings is just like any object i.e. metadata and we cannot migrate our custom settings records using Change sets.
(Source: Custom Settings Image by Trailhead )
Here, ‘Custom Metadata Type’ comes into the play. Using custom metadata type we can easily migrate configuration data along with their associated records using change set and packages.
(Source: Custom Metadata Types Image by Trailhead )
Custom Metadata Types Security and Sharing
When we create custom metadata type, we can choose:
- All Apex code and APIs can use the type, and it is visible in Setup (public) – Custom metadata type available publically and all apex code (not only from the same installed managed package) can access this custom metadata type.
- Only Apex code in the same managed package can see the type. (Protected) Custom metadata type is available internally and only installed the same managed package can access this custom metadata type.
Custom Metadata Records Security and Sharing
We can also control the visibility of individual records. A record can be marked as private or protected.
A protected record is accessible only in its own namespace whereas a public record is available to the entire org.
The above check box is available on record edit page.
Managing Fields on Custom Metadata Type
We can manage custom fields which are associated with custom metadata type by choosing one of the 3 options:
- Only package developer (via package upgrade): - The package developer can edit the field after deployment via package upgrade only, not editable in the org in which it is deployed.
- Any user with Customize Application permission (package upgrades won’t override the value): - The field can be edited in the org in which it is deployed but cannot be overridden via package upgrade.
- No one: - Neither the package developer nor the org in which the package is deployed can edit the field once the package is released
Creating Record on Custom Metadata Type
A user can create records on custom metadata types in the same way as on custom objects.
Here “Marketing Queue” is an example of Custom Metadata Type, on the detail page of custom metadata type. A user can see a button named “Manage Marketing Queues”, by clicking on that button user will be directed to record creation page.
By clicking on a new button the user can create records associated with the specific Custom Metadata Type.
Deployment Steps for Custom Metadata Type
While deploying custom metadata type user can choose from managed packages, unmanaged packages, and managed package extensions. The process of adding the custom metadata is similar to the other packaging types, with just one difference rather than selecting the component type, a user has to select specific custom metadata type.
After selecting custom metadata type user can select records (related with that custom metadata type only) which they want to add to change set, only chosen records will get added.
Use of custom metadata type is highly recommended because it is customizable, deployable, package-able, and upgradeable metadata and it makes our life significantly easier.
to contact us for more information