Hello, I am creating a sign up app and based on what the user selects, I need the app to output to an sharepoint table called "Responses" so that an upstream process can use it. I am very new to PowerApps and am struggling to accomplish this without the ability to code or create a for loop. I have attempted to use multiple ForAll functions, but this does not appear to be working as I intended.
In my app, the user can sign up for multiple reports for multiple different operations, so I have two list boxes for each of these steps. During the "Report" step, the user could sign up to receive report A & B for example, and in the "Operation" step could sign up for operations C & D. Upon final submission on the confirmation page of the app, I want to update the "Respones" table with all possible records from the selected items in the list boxes, along with the users email for all records.
Desired output is below from example:
| Email | ReportSelected | OperationSelected |
| user@email.com | A | C |
| user@email.com | B | C |
| user@email.com | A | D |
| user@email.com | B | D |
However, my function is not working, although it compiles it simply writes the last selected option in Operation for all records instead. It does correctly cycle for one column, but the other column does not change as intended. In the code below SelectedReport is a table with length 2 compiled from the Report list box, same is true with SelectedOperation.
Current code below on the final submit button is as follows:
If(BreakdownRadio.SelectedText.OptionText = "Operation",
Set(varRecord,
ForAll(SelectedOperation,
ForAll(SelectedReport,
Patch(Responses,Defaults(Responses),
{ResponseId:CountRows(Responses)+1,
EmailAnswer:EmailInput.Text,
ReportSelected:Value,
OperationSelected: OperationList.SelectedText.Value}))))
Current Output created, which is wrong.
| Email | ReportSelected | OperationSelected |
| user@email.com | A | D |
| user@email.com | B | D |
| user@email.com | A | D |
| user@email.com | B | D |
I was chatting with this @Geeks_D on another thread, and he suggested the following, but thought I would create a new thread.
"use collection and a ForAll with AddColumns
When Items are selected in OperationsList a collection is created for all selected Items
After the selection a new collection is created with a ForAll function to add the required values from the other list "
The logic of it makes sense but I'm struggling to functionalize the logic in PowerFX and am looking for some additional guidance on how to accomplish this.
For anyone who is working with only a single list box, please reference this solved thread which has an excellent solution from @Geeks_D.