Salesforce Configuration from Custom Metadata Types



Salesforce Configuration from Custom Metadata Types

Custom Metadata Types are a very powerful capability in the Salesforce platform it can in process builder, formulas, and validation rules. I wanted to give some background and examples to help admins understand how it could be used in their orgs. The main advantage to using the custom metadata types is you can add both definition and records in the package or changeset.

Advantages to Custom Metadata:

1. You can control the visibility of Custom Metadata Types by specifying it as public or protected.
2. We can create fields like Picklist fields, long text areas also able to do with page layouts, and validation rules.
3. Asynchronous (without using remote site settings) insert/update in Apex via Metadata.MetadataOperations.enqueueDeployment()
4. Custom Metadata have a option for access for edit the records with “Configure Application” but you require “Author Apex” to edit the configuration.
5. Custom metadata is also visible for test class so no need to insert records for testing.

Some use case are following :

1. Process Builder with Formula

We have a requirement to update one field dynamically and admin can easily update accordingly without renovate the Process builder.

Step are following :
1. Create Custom Metadata for default value with the help below snapshot :

2. Create Records in Custom Metadata with the help below snapshot :
3. Create Process Builder for Update Record via custom metadata records with the help below snapshot :
4. Output :

2. Validation Rules

We have a requirement to update Discount field dynamically and admin can easily update accordingly without renovate the validation rule.

Step are following :
1. Create Custom Metadata for default value with the help below snapshot :

2. Create Records in Custom Metadata with the help below snapshot :
3. Create Validation Rule for Check Record before insert or update via custom metadata records with the help below snapshot :
4. Output :

Note : But there is a one limitation that we can't create dynamic error message for validation rule.


For more details : Custom Metadata Types


Happy Sharing...

Everyone has their own favorites, so please feel free to share yours in the comments below!

Comments

Post a Comment

Popular posts from this blog

Salesforce LWC : Compact Layout on Hover

Salesforce LWC With Third Party JS : D3

Communications between Lightning Components : Salesforce