Unable to display the values inside a nested collection

Copper Contributor

Hi,

To spare you the incidental details that are not relevant to the issue, I have made a test SharePoint list with a test Power Apps, expecting the same issue to arise. And it did arise.

This is the entirety of the test SharePoint list:

 

DanielDumaresq_10-1681849565040.png

 

The way this list should be displayed to the users in the app is that there really are three elements:

  • William;
  • Do it again;
  • Cat.

Each of these elements have two sections in this case, but they could have an infinite number of them.

In this example, the Answer #1 has two sections.

I made an app that uses this list where there is a button that will make a Collection where each AnswerNumber is an element, with a table nested inside each element for the sections.

 

DanielDumaresq_11-1681849591986.png

 

This is the Button’s OnSelect code :

 

// Get the list of unique numbers and collect them in AnswerNumbers
ClearCollect(
    AnswerNumbers;
    RenameColumns(
        ForAll(Distinct(
            ShowColumns(
                PowerAppsBugTestList;
                "AnswerNumber"
            );
            AnswerNumber
        ); {Result: ThisRecord.Value});
        "Result";
        "Value"
    )
)
;;
// Start again on click of the button
ClearCollect(ConsolidatedAnswers;Blank())
;;
// Collect all the answers (unique numbers) and define the columns of the sections table for now
ForAll(
    AnswerNumbers As UniqueNumber;
    Collect(
        ConsolidatedAnswers;
        {
            AnswerNumber:LookUp(PowerAppsBugTestList;AnswerNumber=UniqueNumber.Value).AnswerNumber;
            AnswerData:LookUp(PowerAppsBugTestList;AnswerNumber=UniqueNumber.Value).Titre;
            Sections: Table({
                SectionDataA: "";
                SectionDataB: "";
                SectionNumber: 0
            })
        }
    )
)
;;
// Now collect the sections, which correspond each to one item of the SharePoint list
ForAll(
    PowerAppsBugTestList As ListItem;
    Collect(
        LookUp(ConsolidatedAnswers;AnswerNumber=ListItem.AnswerNumber).Sections;
        {
            SectionDataA: ListItem.SectionDataA;
            SectionDataB: ListItem.SectionDataB;
            SectionNumber: ListItem.SectionNumber
        }
    )
)
;;
// Remove the first record
ForAll(
    ConsolidatedAnswers As Answer;
    Remove(Answer.Sections;First(Answer.Sections))
)

 

 

The red table, “ConsolidatedAnswers”, displays ConsolidatedAnswers. When you select an item, it will UpdateContext({SelectedAnswer;ThisItem})

The two other tables:

  • The green table, “SelectedAnswer.Sections”
  • The blue table, “First(ConsolidatedAnswers).Sections”

Are supposed to display what it says in the label, but they fail to do so.

Two things I’ve found:

  • The record is given to SelectedAnswer, but the nested table Sections contains “”, “” and 0 instead of the actual values.
  • I can’t display the nested table “Sections” in a gallery.

The record is given to SelectedAnswer, but the table Sections contains “”, “” and 0 instead of the actual values

Here, I have clicked the button, and then I have selected the first item, the answer number 1. Power Apps tells me that SelectedAnswer does contain that record.

 

DanielDumaresq_12-1681849674609.png

 

But on closer inspection, I see that the nested table, “Sections” only contains the template values instead of the actual values that were added in the following command.

 

DanielDumaresq_13-1681849686716.png

 

I can’t display the nested table “Sections” in a gallery

Power Apps tells me that I have the actual values in the nested table.

 

DanielDumaresq_14-1681849725891.png

 

But they can’t be displayed in the gallery.

 

DanielDumaresq_15-1681849740524.png

Unless I arbitrarily change the formula. Then it works.

 

DanielDumaresq_16-1681849750634.png

 

Until I save, quit, come back, and click the button again. Now it doesn’t.

 

DanielDumaresq_17-1681849757781.pngDanielDumaresq_18-1681849769862.png

 

If I change the formula to First again, then it works again. Until I save, quit, come back, and click the button again.

I also tried with LookUp(ConsolidatedAnswers;AnswerNumber=2).Sections, it’s the same problem. It works at first, until you save, quit, come back and click the button again.

Interestingly, Gallery1.Selected.Sections contains “”, “”, and 0.

It’s not only galleries that are affected. The same problem applies to labels:

 

DanielDumaresq_19-1681849781725.png

 

This formula worked the first time. It displayed “Power Apps” which is the value it was supposed to display. I saved, quit, came back and clicked the button again, and now it’s blank.

Anyone knows a solution to this problem?

Thank you,

0 Replies