A Variable of the Collection Filter in Flows

visual-workflow

Inserting the new Collection Filter element (resp. FilterCollectionProcessor) (54.0) in a flow, one gets a new "Record Single Variable" that appears under Resources, per default with a name like "currentItem_MyElementName". As the name indicates: it's not a collection. It is available for input and output however, and it appears as a proper variable in the WSDL of the Metadata API. What is the importance of this variable?

The question is not regarding the collection used for referring to the filtered list – which is not a variable at all in terms of the Metadata API. Astonishingly for me, the documentation states:

A Collection Filter’s output collection is named after its API name. For example, if a Collection Filter element is named FilterLeads, its output collection is called CurrentItem_FilterLeads.

Maybe I've misunderstood something? Adding the variable e.g. in a RecordDelete later in the flow, I can activate the flow, but when run – "We hit a snag": "No records in Salesforce match your delete criteria." Better use the collection! (Maybe this is related?!)

I'm facing generally difficulties to find documentation regarding flows. E.g. in the documentation of the flow Metadata API, not only the above element, but all FlowCollectionProcessors seem absent. Is there a more exhaustive flow documentation?

Best Answer

Unofficialsf has the following info in "additional usage notes" from its sneak preview written by VP of Product Management (covering Flow):

The CurrentItem Variable Persists After Collection Filter is Removed

When the new Filter Collection element is inserted into a flow, a record variable called CurrentItem_FilterElementName is automatically generated and added to the flow to provide a way to use formulas and expressions for filtration.

If the Collection Filter element is deleted from the flow, the CurrentItem variable will be left as a resource in the flow and will need to be deleted manually.

As such, it's usage is to be leveraged when selecting Formula Evaluates to True within the "Condition Requirements" of the Collection Filter element.

enter image description here

That documentation you linked/quoted was partially correct, but the example given was incorrect as you've noted (documentation has been updated). The document now shows the correct naming

For example, if a Collection Filter element is named FilterLeads, its output collection is called Leads from FilterLeads.

Related Topic