Skip to main content
Group

Custom Metadata Types

Custom Metadata Types provide customers and partners a powerful new configuration engine for your apps. Enterprises eliminate expensive, error-prone, and compliance-obstructing manual processes currently used to manage app configurations. ISVs save 1-2 person-years writing code to manage app configurations. Until now developers have had to build app configurations from data rather than metadata, which made apps expensive to develop and manage. Now you can create configuration _metadata_ and take advantage of the automation tools Force.com provides to package, manage, and deploy metadata.

We use a Custom Metadata Type within a Flow to determine how to assign certain records to individuals. We ran into an odd behavior that I'm hoping someone has some recommendations around:  We updated the Metadata Type with a few more records and updated some of the variables we'd stored in them. We used the Flow to Get Records from that CMDT and since all the records were unique, we had the Get Records set to return Only the first record. We found in testing that in 4 of our 16 scenarios the Debugger would tell us that it could not find any results and would not action as expected when live and tested in a sandbox.  Comparing everything manually showed there was an entry to find, so we switched the Get Records to instead return All records and could see in the Debugger that for those 4 scenarios that it returned the single entry we wanted for each scenario. However, since the result was now a collection, albeit of 1, we couldn't handle it the same as we had been in the past as a single entity.   Our workaround ended up being that we would return all records and then loop through the results, assigning the variables we needed for the Flow within the Flow. Set to loop first to last it would only keep the last result's variables for use later, but since it was only returning 1 result, that wasn't a problem. The design we have in place works, but it would be simpler and preferred if we could get the Get Records to consistently return only a single value.   Has anyone else had a Get Records not return a result from a CMDT when they have it set to store Only the first record vs when they have it set to store All records? Or have any recommendations for resolving such a situation? 

2 answers
  1. Nov 15, 2022, 12:05 AM

    Our original flow would make a determination and then 2 of the branches from that would query a Custom MetaData object to determine if there were a matching record to influence routing

    Our original flow would make a determination and then 2 of the branches from that would query a Custom MetaData object to determine if there were a matching record to influence routingWhat we were fin

    What we were finding was that when these 2 queries were set to store "only the first record" that we would occasionally not get any record returned from either query even though the debugger showed it was passing through those paths.

     

    CMDT Query 2.PNGIf we switched those to "All Records" instead then we would consistently get a result back but as it was then part of a collection of records we couldn't action directly based on that 1 returned record's values.

     

    To work around this, we switched both of our Get Records to return all records and then looped through them to retrieve the values from the single record returned that we needed for later in the flow.

     

    New CMDT Query 1.PNGSince our Custom MetaData records are mutually exclusive we didn't need to worry about getting multiple results. However, it was puzzling that asking the Get Record to return only the first match wasn't consistently working as expected, especially since just switching that checkbox to store "all records" consistently returns the one record we were expecting from the Custom MetaData.

0/9000

We're coming to you LIVE with a new Automate This! episode, first one in 2024, this Wednesday, January 24 at 10:30am PT.

 

My guest presenters @Corinne Rydman and @Warren Walters will share how you can use custom settings and custom metadata types to boost your Flow game.

 

Set the reminder now: sforce.co/AT0124

We're coming to you LIVE with a new Automate This! episode, first one in 2024, this Wednesday, January 24 at 10:30am PT.

5 comments
0/9000

We make quite some use of the Entity Definition field type in our Custom Metadata. Phenomenal feature to configure the behavior of our logic based on dynamic object/field association.

 

However, to my disappointment it seems to not support Fulfillment Order and Order Summary?

The documentation on Entity Definition field types does not indicate specific limitation on these object types, except perhaps on the "union" characteristic.

https://help.salesforce.com/s/articleView?id=sf.custommetadatatypes_relationships_limits.htm&type=5

 

Can someone provide some clarity on this?

0/9000

I stumbled on this when experimenting with SOQL queries for Custom Metadata Type records. It was not previously available and is ideal for detecting a change (especially when we process details from the CMT record for storage in a platform cache).

 

Anyone able to point me to official documentation for the support of this field?

5 answers
  1. Nov 8, 2022, 7:45 PM

    Great catch!  This was an intentional change that went out in the Winter'23 release but it obviously slipped through the cracks when it came to the docs and release notes.  We are on it and will be updating the docs to reflect its "official-ness".

0/9000
0/9000
1 comment
0/9000

When will CMDT be supported by Flows without having to query the database?

 

Process Builder and Formulas support this syntax already {!$CustomMetadata.MySettings__mdt.MySettingsRecord.MyField__c} – when are Flows gonna support it?

 

Thinking of before-save Flows.

10 comments
0/9000

We just hit this very serious limitation on CMDT being used for a custom solution.  

 

Is there a way to extend this?  Can we purchase more?

 

Thanks!

2 answers
  1. May 5, 2022, 8:48 PM

    Hi @Keith Sadler apologies for the delayed reply. I'm the new PM for Custom Schema. We've conducted performance testing recently and have extended the hard limit beyond 10M characters. 

     

    Please open a support case for a request to increase the limits. We will assess your situation and go from there.

0/9000

Trying to update / insert records from a CSV using CustomMetadataLoader and getting this message:  Web service callout failed: WebService returned a SOAP Fault: Cannot flip on commit allowed, disabled by:Commit Not Allowed By DBContext:Protect.Apex.Transaction.Contract-1641932008379 Error Id: 1284665686-420684 (-2026009058) faultcode=soapenv:Server faultactor= Error is in expression '{!upsertCustomMetadata}' in component <apex:commandButton> in page custommetadatarecorduploader: Class.MetadataService.MetadataPort.upsertMetadata: line 9261, column 1 Class.MetadataUtil.upsertMetadataAndValidate: line 158, column 1 Class.MetadataUtil.transformToCustomMetadataAndCreateUpdate: line 124, column 1 Class.CustomMetadataUploadController.importCSVFileAndCreateUpdateCmdRecords: line 144, column 1 Class.CustomMetadataUploadController.upsertCustomMetadata: line 52, column 1  Any ideas?

1 answer
  1. Jan 13, 2022, 9:55 PM

    We have a migration script that deploys CMT and it is randomly hitting this error as well. Re-running it always works so it seems to be a random SF bug that happens when deploying CMT records.

0/9000