Collection Filter Element

 

  • Collection Filter Element

     This is new in Spring '22


    Collection filters allow us to remove records from a collection.

    In this example flow, we will add a filter to the previous collection sort flow to remove any contacts that have been deleted (and are sitting in the recycle bin, waiting to be permanently deleted in 15 days).



    Since we already have a flow that does most of what we want (from the previous flow we built), open that one and save as A New Flow and name it Account-collection-filter.



    We still need the recordId variable we defined previously.



    Get records remains the same.



    After the Get Records, add a new element - Collection Filter.

    Configure this to filter out the deleted records from the result of our get records.



    We need to change the collection sort we used previously to use the result of our collection filter so we are sorting our filtered collection.



    The Datatable component does not seem to recognise the record collection from the collection filter element so we need to create a variable to copy it to.

    Note: As this variable is only used inside our flow, there is no need to make it available for input or output.



    Add an assignment element and copy the filtered collection to this new variable.



    Edit the Datatable element to use our new filtered collection of contacts:



    Save, Activate and run the flow in debug mode:



    Delete one of your contact that is shown in the debug output shown above and then run the flow again.

    You should have one new contact and the deleted one should be removed.



    Note: You can undelete the contact later by using the Recycle Bin (available from the App Switcher)




No comments: