cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MrNappa
Advocate V
Advocate V

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (25,279)