Another Salesforce blog!!!

Salesforce, Apex

How to create apex trigger on custom metadata type!

How would you implement a reserved words in a standard page layout using trigger/apex class

Let’s imagine that you want to add some sort of reserved words which you don’t want your team to use when creating a records, how would you do that?

Let’s first create an Custom Metadata Types and give it a name as shown below:


After you created the Custom Metadata Type, lets entered some data (reserved words)!

Now, lets create a new custom field in the Account object just for demo purpose:

Now, that you have setup everything lets jump on to Apex class helper:

Now, you have your Apex class helper lets create a class where it validates the reserved words:

Almost there, lets create a trigger that class the above Apex class AccountTriggerHandler.

Its all wired up and let test our solution:

Yay, congrats you have successfully implemented reserved words using Custom Metadata Type!

Enjoy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *