Currently, Summer’19release is available under the pre-release program.On the 3rd and 4th of May, Sandboxes will be upgraded; as a result, your organization will get the look and feel ofSummer’19 release. In this release, you will find lots of new features, as well as, new enhancements related to Lightning Experience, Lightning Flow, Lightning Web Component, Apex, Communities, and APIs.
What is a Custom Metadata Type? Why should one use it? How should one use it? And, last but not least, how is Custom Metadata Type related to, or different than, Custom Object? Well, let us explore these concepts together!
Custom Metadata Type is similar to a custom object – it allows application developers to create custom sets of data, as well as to create and associate custom data with an organization. All custom metadata type data is available in the application cache. As a result, it allows efficient access to the data without the cost of repeated queries (SOQL) to a database.
Custom Metadata Type is mainly used to store information that will be frequently accessed from Apex code. Custom Metadata Type performs better than a custom object because it is available in cache; and therefore, it does not have to be queried. The other difference, which you will notice between the custom metadata type and a custom object, is the difference in the suffix. Custom Metadata type has __mdt suffix at the end of the custom metadata type, as opposed to the usual __c for custom objects. As of the Summer’17 release, custom metadata is not yet available in Process Builder. However, it is currently available in Visual Workflow.
Business Use Case
Let us start with a business use case. Pamela Kline is working as System administrator at Universal Containers. At UC they are using Chatter extensively for internal communication to manage Sales and Support. Business Users are often using Chatter to ask help from Internal Salesforce team regarding how to use some feature.
Pamela has received a requirement to auto-create a case whenever a new Chatter post (not a comment) contains a keyword word. She received a list of keyword words (almost 11 words) from her manager. Pamela’s task is to ensure that only a single case is created even if Chatter posts contain numerous keyword words.
Solution for the above business requirement
There are various ways to solve preceding business requirement. Few of them are following:
Create an Apex Trigger on the FeedItem object – We will work on this option in our upcoming Apex Series.
Use all 11 keywords in a Process Builder (On feedItem object) entry criteria and use the Create a Record action to auto-create a case. The problem with this approach, however, is that if, after few days, the business wants to add or remove a few keywords, then you have to start from scratch again.
Use Custom Setting to store the keywords and then use Process Builder to manage your logic.
Use Custom Metadata Type to store the keywords and then use Visual Workflow and Process Builder to manage your logic. Custom metadata provides the flexibility to add or remove keywords without having to change your Process definition or Flow.
List of Keywords: – Ohana; Salesforcehelp; help; TrailheaDX, MidwestDreamin, SoutheastDreamin, IndiaDreamin, TDX17, SalesforceOhana, JDF17, dreamOlé
To solve the preceding business requirement, we will take the 4th approach. We will use – (i) custom metadata type to store the keywords; use (ii) Flow to compare the keywords with the Chatter post body; and, use Process Builder to launch the Flow. Perform the following steps to solve the preceding business requirement:
To create a new custom metadata type, navigate to Setup (Gear Icon) | Setup | PLATFORM TOOLS | Custom Code | Custom Metadata Types and click on the New Custom Metadata Type button. Now fill the form as mentioned in the following screenshot: