Filter list to not show item with empty relation table

Good Day

How can I filter list to not show item with empty relation table, for example…

I have a “customers” table which has a relation to “vehicles” table, in other words a Customer has a list of vehicles. I would like to show this list on a table, but hide customers who do not have vehicles. I have tried the following code but I get the below error…

Kind Regards

Hi Donovan,

Have you tried adding print blocks to see what the values are as the logic runs?

Regards,
Mark

Good Day @mark-piller

Thank you for your assistance. I have added a print block to every step as seen below, hopefully you can spot something I missed.

Screenshot 2022-05-25 at 12.53.44

This is the result…

So here is a couple things I notice,

  • There are 4 customers but only three are shown in the list at the start on the sequence, however if the “in list get ‘customers’ of currentCompany remove # counter” block is made inactive all four customers is shown. The customer not shown does have a vehicle relation

  • The customer without a vehicle is recognised but the “in list get ‘customers’ of currentCompany get # counter” block shows undefined, and the customer is not removed.

Kind Regards

Hi @Donovan_Hardwick,

could you please click on the bundle.js:33:47 (when an error occurred in your console log) and show us what you see there?

Regards,
Stanislaw

Good Day @stanislaw.grin

Kindly see below.

Kind Regards
Donovan

Thank you, @Donovan_Hardwick!

You don’t need to remove items from the list manually. In order to retrieve filtered currentCustomers, you should return true/false from the Filter Items in list` block. So you can basically do your checks in this block and if you need to remove item, just return false, otherwise - true.

Regards,
Stanislaw

@stanislaw.grin

Wow I never knew that was possible, I just learned something new!!! Thank you.

Kindly check the below code to see if it is correct, it seems to work.

Screenshot 2022-05-25 at 14.02.33

Kind Regards
Donovan

It’s fine :slight_smile:

Regards,
Stanislaw

Here’s a video from the Codeless training course about list filtering:

Thank you @mark-piller