0

I am trying to use the records entered the schedule triggered flow as a collection variable so that I can use it in the loop elemetn in the flow

There is condition for the records to enter a schedule-triggered flow in SF already.

The start element in my flow has the same condition as the Get Records element.

In the loop element, it needs a collection variable (currently I am using the collection variable from the Get Record Element and everything is working with no issue).

When I tried to save my flow, SF gives a warning saying below

These issues don't prevent activation, but can cause problems when you run the flow. Get_Lead_in_Journey_Active_Status (Get Records) - The “Get_Lead_in_Journey_Active_Status” Get Records element in this flow can cause performance issues. At run time, the flow starts an interview for each record specified in the Start element and stores each lead in the $Record global variable. Check whether the “Get_Lead_in_Journey_Active_Status” element is still necessary, or add a filter so that the element accesses only the lead in the $Record global variable.

Is it redundant to have to define a get records element with the same condition as the start element? If so, is there a way to reference the collection varibale that has all the records enetered the scheduld flow?

Seems the $Record global variable is not a collection variable I can use in my Loop element. It really confuses me why SF is giving this warning. What can I do to prevent this warning from showing up ?

enter image description here

1 Answer 1

0

Salesforce creates an "interview" for each record in a Scheduled Flow when using a Start Object. This allows Salesforce to control the batch size for the processed records, yet give the appearance of each record running simultaneous with the others, as if they were separate transactions. In other words, if you get all the record in a Get Records element, you will duplicate the work you're doing a number of times equal to all of records that meet the entry filter criteria. That's why this warning exists, because you will be wasting a lot of resources.

If you need to process all the records at once, do not set a Start Object and use Get Records to get all the records you need. Otherwise, if you want to efficiently process every record, and they are independent of each other, don't use Get Records, just look at the record in $Record. If you need to compare some records to others, you can also use an appropriate filter in Get Records along with the Start Object configuration.

4
  • sorry not quite follow your commnets: If you need to process all the records at once, do not set a Start Object and use Get Records to get all the records you need. The 'Start' element has a mandatory requirement for inputting the Object type (Lead in my case) and entering condition. If I don't put any entering condiiton, it will be for all leads, which is not what I want) With all the leads entering the schedule triggered flow, I need to use a Loop element to get through each of the lead. The Loop element requires a collection variable.
    – Yang
    Commented May 25, 2023 at 17:15
  • The comment has character limit.... Just want to finishing up the previous comment: If I don't use 'Get Records' element, how do I have the Collection Variable for the Loop element to use? Thanks!
    – Yang
    Commented May 25, 2023 at 17:19
  • @Yang The Scheduled Flow feature allows you to just run a flow (no records), in which case you can use Get Records. However, this means all records will be processed in a single transaction. When you set the Start Object with filters, you then allow Salesforce to create multiple transactions to process all the records, much like the Batchable interface works. In that case, each record is its own interview, and the record is held in $Record. You do not need to loop over a collection in this case.
    – sfdcfox
    Commented May 25, 2023 at 17:44
  • OK. I see. Thank you for your explaination. I think there is a known issue with schedule triggered flow issues.salesforce.com/issue/a028c00000qKOb4AAG/… I was not able to delete the object in the start element once it is set.. Didn't realize the object in the start element is optional.....
    – Yang
    Commented May 26, 2023 at 2:29

You must log in to answer this question.

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