Apr 18 2023 01:33 PM
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:
The way this list should be displayed to the users in the app is that there really are three elements:
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.
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:
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 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.
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.
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.
But they can’t be displayed in the gallery.
Unless I arbitrarily change the formula. Then it works.
Until I save, quit, come back, and click the button again. Now it doesn’t.
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:
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,