To fix the "Too many SOQL queries: 101" error in your Flow, follow these steps:
Step 1. Use "Fast" Elements Instead of Regular Record Elements
Replace any Record Lookup, Record Create, or Record Update elements with their bulk-processing counterparts: Fast Lookup, Fast Create, and Fast Update.
Fast elements handle multiple records at once, reducing the number of queries used.
Step 2. Move All Lookups and Updates Outside Loops
Check if any Get Records, Update Records, or Create Records elements are inside a loop. Move these elements outside of the loop.
Instead of updating records one by one within a loop, use Assignment elements to collect all updates in a single collection variable.
Step 3. Use Collection Variables with Assignment Elements
For bulk updates, store records in a collection variable by using Assignment elements inside the loop.
Once all records are assigned to the collection, use a Fast Update element outside the loop to process them all at once.
Step 4. Use Decision Elements to Minimize Updates
Add Decision elements before Update or Create actions to ensure updates only happen when necessary. This reduces unnecessary database interactions.
Step 5. Consolidate Queries
Combine multiple Get Records elements for the same object into a single query when possible. This reduces the overall number of queries.
Step 6. Test the Flow with Bulk Data
Test your Flow with bulk data to ensure it doesn’t exceed the query limits. This is especially important when processing large batches, as they’re more likely to hit the SOQL limit.
By following these steps, you should see a significant reduction in SOQL queries used in your Flow, helping you avoid the "Too many SOQL queries: 101" error.
Learn more about Salesforce here.