Does Query for Custom Metadata Types Count Under SOQL Limit?

 In a single transaction we can run a maximum 100 SOQL queries, therefore it is important to understand if a query for custom metadata is included in this limit.


A common answer: No. You can run unlimited queries for custom metadata types.

The right answer: it depends.


First, the "unlimited" is relevant only for apex code. Querying custom metadata types in a flow does count as query.


But also when using inside apex there is one exception: Does your query contain long text area field?


We can access custom metadata types in two methods:

    1.Custom metadata methods (getAll/getInstance)

    2.SOQL query


If you are using the first approach it will never be counted as a SOQL query but for long text area fields you will get only the first 255 characters.

Using the second approach, will always return full content of the long text area fields, but will count as SOQL query.


The following examples can help to understand the differences



1 comment:

Retire of Permission on Profiles

If you are working as a Salesforce admin/developer you've probably heard somewhere that Salesforce is planning to make a significant cha...