[✅ Solution] Filtering on related not as expected

Hi this is following on from: How to filter Get records of a view?

I believe @Luis got things working using a variation on my ‘Option Two’ however he also sent me a link to his workspace and on looking at it the key part preventing it from working was that he was filtering on a collection gained from a ‘get related’ block rather than a plain search.

I have modified my original test workspace to match his and this produces results that are not how I would expect:

I am not sure if this is working ‘as intended’ but if it is it is definitely not as Luis or I would expect.

5 Likes

Thank you, @Jason, for reporting the bug. It was confusing when I was building the automation and the filter didn’t…well…filter like I was asking.

3 Likes

Many thanks @Jason and @luis,

you’re absolutely right, I wouldn’t expect that either. Very confusing indeed, as you already suspected it’s a bug, probably in the code generation. I will get back to you as soon as we have understood and fixed the issue.

Best regards and special thanks for the detailed review of the issue!
Leo

@Jason thanks for sharing your issue and the detailed explanation.

Would it be possible for you to provide a share-link with the dummy workspace that you used for testing? I could then reproduce (and hopefully quickly resolve) your issue more efficiently by executing and observing the behaviour shown in your screenshot. You could also send me DM with the share link.

Cheers
Tim

1 Like

Hi all,

thankfully, @Jason was able to share the workspace and workflow with me to analyze it in detail.

Here’s what the flow from the screenshot does:

  1. The flow grabs all records from the view listA in App A - that is 5 records.
  2. Now, we get the related App C records of the current record B, which yields the two "dont list "records from C (with email address a5 and a3).
  3. Now for the important part: We filter the record collection from 1) using an email filter with DOES NOT CONTAIN and use the Collected App C Email token. What is important here: As for all collections, this token only contains the first found record’s email (a5 or a3 depending on the order), as usual for collections. This is the specified behaviour to allow users to search for a single record, and use the resulting collection’s record values right away. Combining multiple record’s field values from a collection with multiple records would not be trivial and also not fully intuitive - think about different field types etc.

As in 3) the first found record is used, only one email is filtered out yielding 4 records as printed.

While we would agree that one might argue that this is not 100% intuitive - it is the specified behaviour indeed. We had to make the trade-off that collection tokens only contain the first record. If you need to access field values from multiple records of a collection, a loop is required.

Consecutively, what you could do in this scenario: Loop over the collected Cs and apply the FILTER COLLECTED action on each iteration. This way, you filter out all the found C’s emails. I tried that and it spits out the desired outcome, 3:


Screenshot 2024-04-18 at 12.15.21

@Luis @Jason thanks for sharing your case, I do hope this resolves your questions and helps you in the future should similar scenarios occur.

Cheers
Tim

2 Likes