I was having a bit of trouble getting values of a lookup field during a load. First, some background the relevant data structure. It is set up like this: A [Project] contains [Ruimtes]. [Ruimte] contains [Elements]. [Element] contains a lookup value to an [Elementdefinitie]. This last one is the value I'm trying to retrieve.
Basically, what I'm trying to do, is collecting certain fields from a data set into a local collection, so I can group/display it later. Simplified, it is set up like this:
ForAll( Filter( Ruimtes, <belonging to project> ),
ForAll( Filter( [@Elements], <belonging to this Ruimte> ),
Collect( myCollection, {
definitieId: Elementdefinitie.Elementdefinitie
});
);
);
(The 'myCollection' collection is used later on for displaying things and also contains other stuff, but that's not really relevant here)
However: the problem is that the ID i'm trying to collect is always empty!
Side note: the 'Explicit column selection' preview setting is turned on in my app. However, I also tried with this setting off, and it gives the same results.
I've done quite a bit of digging trying to get the root of this.... but I finally came up with a workaround: if I use the 'Elementdefinitie' column in the filter, the value returns fine. So this works:
UpdateContext({g: GUID("") }); // dummy guid
ForAll( Filter( Ruimtes, vdt_ParentProject.vdt_projectid=dayPlanning.vdt_projectid ),
ForAll( Filter( [@Elements],
vdt_ParentRuimte.Ruimte=vdt_ruimteid,
vdt_ElementdefinitieId.Elementdefinitie<>g )
,
Collect( testColl, { defId: Elementdefinitie.Elementdefinitie } );
);
);
After a bit of more testing, I concluded that the core problem seems to be the [@..] scoping that is used because of the nested structure:
// This works:
ForAll( Filter( Elements, vdt_ParentRuimte.Ruimte=<fixed guid> ),
Collect( testColl: { defId: Elementdefinitie.Elementdefinitie } );
);
// This doesn't:
ForAll( Filter( [@Elements], vdt_ParentRuimte.Ruimte=<fixed guid> ),
Collect( testColl: { defId: Elementdefinitie.Elementdefinitie } );
);
Is there something at work here with regard to scoping that causes this, and I don't fully understand it? Or is this a bug?