Say we have a record-triggered flow that calls invocable Apex. The Apex class uses SOQL to query custom metadata and return a value to the flow. Does the Apex custom metadata query count against the SOQL limits for the Flow transaction?

This article says that Apex does not consume SOQL queries when retrieving Custom Metadata, but "SOQL queries for custom metadata type records in flows" do count against the limit: https://help.salesforce.com/articleView?id=sf.custommetadatatypes_limits.htm&type=5

Is the invocable Apex considered a "SOQL query in the flow"?

I know I could write this entirely in Apex instead of a Flow/Apex hybrid, but the client wants to use Flow as much as possible.

I've opened a case with Salesforce but was wondering if anyone has run into this already.

  • 1
    this, of course, is amenable to experimentation - just have your invocable apex do a loop with 101 SOQL against the custom metadata run the flow
    – cropredy
    Commented Jul 2, 2021 at 0:20

1 Answer 1


CMDT Queries performed in Apex do not count against the limit. They are specifically referencing queries performed by Get Records. I actually did take the time to test this, as @cropredy suggested, and successfully performed 1000 CMDT queries in a single Apex Action without a problem.

  • One caveat to this is that if there is a text area long field in the metadata object that you're querying against and you include this field in your soql it will count against the soql limit Commented Oct 12, 2021 at 20:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .