Summer’17 :: Retrieve and Deploy Metadata through Apex
In Salesforce World, Metadata plays a very important role. Metadata types and components are used to represent org specific configuration and customization. Salesforce is having a very good page explaining Metadata. Here is the link – “An Introduction to Force.com Metadata”. Before Summer’17 release, in order to access Metadata, you need to use the Metadata API, but now Salesforce comes up with Metadata namespace. You can use classes in Metadata namespace to access Metadata components through Apex.Why do I need to access Metadata?Salesforce documentation explains it correctly and here are the possible reasons why you may need to access Metadata.In this post, I am going to explain how you can access and deploy Metadata changes through Apex with an example.Example -In my Salesforce Org, I have one Custom Metadata Type named – “Admin Preference” which is -The values of this Custom Metadata Type are -Now I will create a simple VisualForce Page which will retrieve this Metadata Values and display them. At the same time from the same page, I will change the values. To implement this requirement, I will use the Salesforce Summer’17 New Feature – classes Metadata namespace.Let’s Start -In order to store the Custom Metadata Values, I will use the below class -public class MetadataHelper{ public String name {get;set;} public Boolean isEnabled {get;set;} public MetadataHelper(String name, Boolean isEnabled){ this.name = name; this.isEnabled = isEnabled; } public String getFullName(){ String fullName =...
Read More