Salesforce Fact #953 | Limit error in Get Records while using IN operator

We need to be careful while using the IN operator in Get Records element in record-triggered flow.

If the text collection is empty, it seems Salesforce runs a query to fetch all the records of that sobject and the number of query rows are counted in the governor limit. So, if the total number of records for that sobject is more than 50000, it throws limit error.

Fix would be to always check if the collection is empty or not, before using it in the IN operation.

In this example, varIds is an empty text collection used in IN operation to fetch the account records. However, the number of query rows returned is 136 instead of 0, which is the total number of account records in the org.

Attached are the screenshots.




Comments

Popular posts from this blog