0

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.

enter image description here

enter image description here

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).

enter image description here

The second step gets the Content Version (CV) record related to the CDL via the Content Document Id field on the CDL.

enter image description here

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).

enter image description here

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.

enter image description here

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?

3
  • Looks like the initial criteria of the flow is not correct.All the Account records in your org will satisfy the entry criteria of the flow as every record's id will not be null.Try rewriting the entry criteria to get your required accounts only. This is my 1st time answering someone and I am not very much experienced in Salesforce yet but I assume that might be the problem in your case.
    – Hira Khan
    Jul 12 at 18:21
  • This is really a comment, not an answer. With a bit more rep, you will be able to post comments. For the moment I've added the comment for you, and I'm flagging this post for deletion.
    – identigral
    Jul 12 at 21:33
  • Hey Hira. Welcome to the community. Thanks for your feedback. It is my intent to review every Account record every day. I believe the Scheduled flow framework SHOULD allow that, unless I'm mistaken.
    – Jack Odell
    Jul 13 at 18:58

2 Answers 2

0

So there's a neat thing you can do with scheduled flows where you don't have to specify the object you want to start with. So how I would go about it, is to create an empty scheduled flow(no Start object) and get my records using the Get Records action and assign them to a collection and go from there.

I would also recommend to bulkify any dml statements you make too.

i.e, Get Records -> change Records -> assign to collection -> update Collection Sample assignment to collection

0

I think your requirement is to check for all accounts in org. Even in scheduled flow we are flooding more than 100s of accounts into the flow to get respective content document links.Salesforce has a governor limit that in a single transaction we can query only 100 queries together.This will try to query all the Content Document Links of those accounts which might be the cause of your error.

1
  • You do describe the cause of the issue, but don't suggest a solution. Could you edit the answer to suggest some ideas?
    – Matt Lacey
    Jul 19 at 14:56

You must log in to answer this question.

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