cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MrNappa
Kudo Collector
Kudo Collector

Bug? (lookup) column value is not loaded

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?

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @MrNappa ,

Based on the needs that you mentioned, I think it is not necessary to add the [@] Disambiguation operator to wrap the Elements data source.

 

The [@] Disambiguation operator is usually applied to field name within a Data Source, which may have same name as the field in another data source. Please check the following article for more details:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/operators#disambiguation-oper...

 

On your side, please consider modify your formula as below:

ForAll(
      Filter(Ruimtes, vdt_ParentProject.vdt_projectid = dayPlanning.vdt_projectid),
      ForAll(
             Filter(Elements, vdt_ParentRuimte.Ruimte = vdt_ruimteid),  // Remove the [@ ] Disambiguation operator from the Elements data source
             Collect(
                      testColl, 
                      {
                         defId: Elements[@Elementdefinitie].Elementdefinitie
                      }
             )
      )
)

 

In addition, if you want to distinguish the same field name from different data sources, I think the RenameColumns function could also achieve your needs. E.G.:

ForAll(
      Filter(Ruimtes, vdt_ParentProject.vdt_projectid = dayPlanning.vdt_projectid),
      ForAll(
             RenameColumns(
                           Filter(Elements, vdt_ParentRuimte.Ruimte = vdt_ruimteid),  // Remove the [@ ] Disambiguation operator from the Elements data source
                           "Elementdefinitie",
                           "Elementdefinitie1"
             ),
             Collect(
                      testColl, 
                      {
                         defId: Elementdefinitie1.Elementdefinitie
                      }
             )
      )
)

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-xida-msft , thanks for your reply.

 

I tried removing the disambiguation operator from the nested ForAll filter already, however as soon as I remove it, an error message tells me that the function 'Filter' has invalid arguments "the specified column is not accessible in this context". This is because powerapps seems to also generate a 'Elements' property for 'Ruimte' ( I think this may be because there's a parental relationship between the two but I'm not sure -- what I do know is that there's no user defined field by me with that name ).

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,284)