Hi folks
I have two tables: One is called “Products” the other is called “Product Components”. As you can imagine there is a (1:N) link between them, so a Product can have multiple Components. A Component has a single Product.
Here is what I am trying to do: I need to fetch all Components for a Product.
I have a RecordQueryResults called “allComponents”. product.id contains the Product I’m searching for. Here is my code:
let components = allComponents.records.filter(record => {
(record.getCellValue(“Product”).map(x => x.id).includes(product.id)) });
After this, if I check components.length I will get zero. It is an empty array.
I tried debugging using console.log inside my filter callback:
let components = allComponents.records.filter(record => {
console.log(record.getCellValue(“Product”).map(x => x.id).includes(product.id));
(record.getCellValue(“Product”).map(x => x.id).includes(product.id)) });
The results are: whenever a Product matches product.id I get TRUE; when it doesn’t I get FALSE. Therefore it would appear that the filter is working.
However, “components” is always an empty array…
Can anyone help me figure this out?
Thanks
Alex
