Getting a list out of a list is returning as 'undefined'

Good Day

I am have a list with three levels namely, “Company”, “Customers” (child of Company, 1:N relation) and “Vehicles” (child of Customers, 1:N relation). As seen in the below screenshot I try to get the vehicles out of the customers but it returns with undefined.

Screenshot 2022-05-25 at 16.49.27

Kind Regards
Donovan

Hello @Donovan_Hardwick,

in your case the currentCustomers is a list of objects (aka array). In order to work with some object inside the list, you need to target it by its index. Currently you’re trying to take vehicles not of some object, but of the list, thus it is undefined.

You need to use this block:

Regards,
Stanislaw

Good Day @stanislaw.grin

Thank you for your assistance, unfortunately I don’t seem to be coming right. I have tried the below but no luck.

Kind Regards

Hi Donovan,

Could you please describe the logic you need in plain English? As algorithmically as possible.

Regards,
Mark

Hi @mark-piller

The logic should be straight forward, get a child list out of parent list. But as @stanislaw.grin stated I cannot use the normal “Get property” block, i will rather have to use the “In list get” block. My goal is to get the “vehicles” listed in each customer into one list called “currentVehicles”

I will need to get the “vehicles” list from each “item” in “currentCustomers” list. In order to use the “in list get” block I need a counter. To have the counter change I will need a loop, that runs for the length of the “vehicle” list in the current “item”. Each “vehicles” i get I set in “currentItem” which is retuned to “currentVehicles”.

Hope this makes sense, what I want to do seems simple but I know I am doing something wrong.

Kind Regards
Donovan

You are describing a solution, but I wanted to get more of the end result with the logic for how to obtain it :wink:

I would like to show this database onto a repeating table, I plan to have different companies use this app with there own customer list and each customer having their own list of vehicles. This information should only be seen by the Users of the current Company.

To stop the 'data leak" I get the current User => Company => Customers => Vehicles list. I unfortunately do not know an easier way to do this, so I have set the current User => Company objectId into local storage data. I then use that objectId on almost every page to get customer information or vehicle information.

On this specific page I would like to display a list of vehicles linked to the current User => Company.

Kind Regards
Donovan

Does it need to be a combined list of all vehicles for all customers for a specific company?

Only customers for a specific company.

Hello @Donovan_Hardwick

You have customers from some sompany

customer1: [vehicle1, vehicle2]
customer2: [vehicle1, vehicle3, vehicle4]

What exactly do you want to get?

customers: [vehicle1, vehicle1, vehicle3, vehicle4]?
Or
customers: [vehicle1, vehicle3, vehicle4]?
Or something else?
Provide us schema you want

Regards

Hello @Donovan_Hardwick,

try the following:

If I understood you correctly, you want to get all vehicles of all company’s customers in a single list. If so, here is the solution.

Please note that in this case, duplication of vehicles in the list is possible if different customers have the same vehicles.

Hope this helps.

Regards,
Stanislaw

Good Day @stanislaw.grin @viktor.liablin @mark-piller

Thank you all for your assistance.

@stanislaw.grin that code is just I needed, I had to slightly change it to only search vehicles on the current customer. Thank you.

Kind Regards
Donovan