I'm trying to write a Scheduled Flow to count how many Notes are related to an Account record.
I have a Scheduled Flow on Account that is configured to walk through all Accounts every day.
The first step gets the most recent Content Document Link (CDL) record related to the Account record via the LinkedEntityId field (sorted by the SystemModStamp on the CDL).
The second step gets the Content Version (CV) record related to the CDL via the Content Document Id field on the CDL.
The third step. updates the Account that triggered the Scheduled Flow & sets a custom field on the Account called Last_Note__c to the TLM of the CDL (which is converted to a date via a formula field).
This flow works perfectly in my dev sandbox with only a couple of Account records. It also works well on the partial sandbox when I limit it to a single Account Id. But when I run it in a partial sandbox with about 7k Accounts and about 3k Content Bodies, I'm getting a strange error.
I get a Too Many SOQL error. But I get the error in a strange place. I would have expected my error to be invoked by updating the Accounts. But instead, my log seems to show that the flow runs the first step multiple times.
Has anyone run into something like this before? Any ideas? Could this be an artifact of the partial sandbox? Or some issue with querying the Content Document Link or Content Version objects via a Scheduled Flow?
Or maybe I need to somehow better handle the use case when the get step doesn't return any records?