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?
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
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.
If 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.
Since 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.