top of page
  • Writer's pictureRachel Martínez

Deep Dive into Setting Up CMDTs for Salesforce Flows: Insights from Cloud Journey Group's Lunch and Learn




Hey there, fellow Salesforce explorers! It’s Rachel Martínez, your guide through the ever-evolving landscape of Salesforce automation and efficiency. Today, I’m thrilled to unpack the specifics of our recent Lunch and Learn session, where we delved into the art of utilizing Custom Metadata Types (CMDTs) to manage record type IDs for Salesforce Flows. Sometime back, one of my favorite Architects and mentors taught me this solution, and I have been implementing it ever since. This journey is about making our Salesforce orgs smarter, not harder, to manage. So, let’s break down the process and make it as digestible as our favorite lunchtime treats!


Setting the Stage with CMDTs

Custom Metadata Types (CMDTs) are like the secret ingredients that make your Salesforce recipes adaptable and scalable. When it comes to handling record type IDs in Flows, CMDTs are particularly invaluable. They allow us to store these IDs outside our Flows, making them easily retrievable and updateable across our entire org, without needing to dive into the code whenever a change is necessary.


The Recipe for CMDT Success

Here’s a step-by-step guide to setting up CMDTs for your record type IDs, inspired by our collaborative discoveries during the Cloud Journey Group's engaging Lunch and Learn session:


  1. Create Your CMDT:

  • Navigate to Setup and enter ‘Custom Metadata Types’ in the Quick Find box. Select ‘Custom Metadata Types’ and then ‘New Custom Metadata Type.’

  • Name your CMDT to reflect its purpose (e.g., RecordTypeIDStorage or Master RecordTypeIds). This naming convention is crucial for clarity and ease of use later.

  1. Define CMDT Fields:

  • For each CMDT, you’ll need two fields to store the 15-digit and 18-digit record type IDs. Create two fields: one for each ID format as a text field and limit the number of characters to reflect the correct digit count. 

  • Consider adding a description field to provide context or notes about each record type ID. This can be especially helpful for future reference or team members unfamiliar with the project.

  1. Populate Your CMDT:

  • With your CMDT structure in place, it’s time to populate it with data. Enter the specific record type IDs you need for your Flows. This might include IDs for different opportunity stages, case types, or any other record types your Flow interacts with.

  • Enter the correct IDs meticulously and double-check for accuracy. Mistakes here could cause your Flow to behave mysteriously!

  1. Leveraging CMDTs in Your Flows:


Now that your CMDTs are ready and populated, it’s time to make them work within your Flows. 

  • Step 1: Create a subflow that can be used in one or more subsequent Flows. Within this subflow, create unique text variables to house the retrieved record IDs. In the Availability Outside the Flow criteria, set Available for output to equal true. Insider Tip: Be sure to match the naming convention of the CMDT records created in Step 1! Again, this naming convention is crucial for clarity and ease of use.

  • Step 2: Use the ‘Get Records’ element in your sublow to query the CMDT records and set the text variable created in the step above based on your criteria. Assign the retrieved record type IDs to variables within your subflow. These variables can then be used dynamically to set record type IDs as records are created or updated, making your Flows incredibly versatile and maintainable.


  • Step 3: Activate your subflow.

  • Step 4: In a subsequent flow where record IDs are needed, create text variables to house the retrieved record IDs. In the Availability Outside the Flow criteria, set Available for input to equal true. I can’t say this enough—be sure to match the naming convention of the CMDT records created in step 1! Again, this naming convention is crucial for clarity and ease of use.

  • Step 5: Add a subflow element to your new flow, manually assign variables to true, and map the output values from the subflow element to the input text variables in the new flow.


  • Step 6: When a record ID is required in your new flow, map the text variable you created, and Voila!

  1. Testing and Validation:

  • Test your Flow thoroughly in a sandbox environment before launching your Flow into the wild. Ensure that it correctly retrieves and applies record type IDs in various scenarios.

  • Pay special attention to edge cases and ensure your error handling is robust. This will save you (and your users) headaches down the road.


The Why

Why go through all this effort, you ask? Great question! The most significant upside to leveraging this solution is avoiding hard-coding IDs. We all know that is a big no-no and can lead to massive headaches after deployments or down the line when automation randomly starts failing. After hours of triage, we realized the record ID was hard-coded.

  1. Flexibility

  • Once deployed to production, you need only update the CMDT records and reset the 15- and 18-digit values to match prod. All of the automations that house CMDT IDs will reflect the change. There is no need to trace down hard-coded IDs to update!

  • Once set in prod and after sandbox refresh, the CMDTs will match in both environments. Easy peasy!


The Collaborative Spirit

Our Lunch and Learn wasn’t just about CMDTs or Salesforce Flows; it celebrated collective curiosity and collaboration. We shared, questioned, and even stumbled through some parts together, emerging with a more robust understanding and appreciation for Salesforce’s capabilities.


Parting Thoughts

As we navigate the vast seas of Salesforce automation, let’s remember the power of tools like CMDTs to make our journeys smoother and more enjoyable. Setting up and utilizing CMDTs for handling record type IDs in Flows may seem detailed at first glance, but with practice, it becomes second nature.


Please take these insights, play around with CMDTs in your orgs, and share your experiences. Salesforce is a journey best traveled together, and every shared insight is a beacon for fellow explorers.


Until our next Salesforce adventure, keep innovating, learning, and, most importantly, sharing those insights. Here’s to making our Salesforce orgs not just more efficient but truly exceptional.


Cheers to our continued journey,

Rachel Martínez




40 views0 comments

Commenti


bottom of page