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](https://support.backendless.com/uploads/default/original/2X/0/061ce5575ffa507636f6aae2d5b633d2d008dceb.png)
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
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](https://support.backendless.com/uploads/default/original/2X/a/a29f9b4b81971f2055015657b10371b3b73afbe7.png)
Kind Regards
Donovan
Here’s a video from the Codeless training course about list filtering: