Custom Metadata is mainly used in configuration settings for managed packages. I’ve been using it to hold data like tax rates, promotion information, and targets which can be brought through in Flows and apex without the fear of it getting overwritten unless you are going through the metadata API.
In other tutorials, I’ve shown getting data from records and, in reflection, could have held encounter statistics in a metadata object for the Flow Battler RPG. This would benefit from being hidden away from the users who may want to change the stats to cheat the game.
Limits
There are, of course, limits to using Metadata information. You don’t have lookups or master-detail, you do have a Metadata Relationship, and you don’t have Rollup fields or formula fields; however, you do have all the main types of fields like checkbox, text, number, date, and date/time to see the complete list of fields you can go here.
How to Use It
You can call it with Apex code and also access it in Flows. As this blog is about Flows we will cover the latter two methods. Custom metadata is available on the Get Records Elements, the same as objects. You can identify a metadata object by the __mdt instead of __c. I have created a metadata object, as an example, seen in the image below.
What we are going to do is use it in a flow as a value-setting source. Similar to what we are currently doing with the Encounter object. So we will quickly run through it, looking up and using the variables down the line.
Flow Battler Meta Version
Follow the Encounter Tutorial for most of it. Some fields you cannot use, like formulas. Please create a new version of the Flow Battler by saving it as named Flow Battler Meta Version pictured below.
Replacing Out the Get Records
The most significant job will be replacing the Encounter Object get elements with Encounters_mdt__c, which is the meta version. Note you will first need to remove the Image Formula as you cannot recreate it. These should be straight swaps, as pictured below. This object label is the same, but the object is Encounters_mdt.
The only field you will need to change is where you display the enemy name as it will be {!Get_Enemy.DeveloperName} instead of {!Get_Enemy.Name}. This will need to be replaced on the victory screen and battle screen, as shown below.
Now you have changed all this, save it. This should run all the same test it out, and if there are any issues, you may have missed something. Metadata objects are also great for storing API keys to direct integration to external systems like Google Calendar. I will create a more straightforward use case for this with tax rates, so be sure to check that out in the future.