So you have a bunch of Context Data issues.
1. you are looping through all the gal_KPIItems.AllItems but you are assigning KPI_Name for instance to gal_KPIItems.Selected.KPI_Name. This will not work, as it will only ever give you the row that is selected, and not the CURRENT row within the loop
2. In the Category you have ThisRecord.KPI_Category, I have have to assume this come from the gal_KPICategory? Which is the Parent (outer loop) but you have ThisRecord, but in your code, ThisRecord is pointing to the current loop of gal_KPIItems.AllItems.
So there are multiple things that will make this not work. I am not even sure you are getting into the Patch loop to begin with.
ForAll(
gal_KPICategory.AllItems,
ForAll(
ThisRecord.gal_KPIItems.AllItems,
Patch(
IDM_KPI_Responses,
Defaults(IDM_KPI_Responses),
{
Title: "Response", // Placeholder
Supplier_Name: varSelectedSupplier,
Category: ThisRecord.KPI_Category,
KPI_Name: gal_KPIItems.Selected.KPI_Name,
Score: gal_KPIItems.Selected.Score_Input
}
)
)
)
Using Context: I updated it below
You will have to complete the updates as you cannot use .Selected you need to use the proper Control OR just a point to the row.
The pointer to the row is normally ThisRecord, but since its an inner loop, and I added alias's its _Parent or _Child
And assuming that Score_Input is a direct property of the Row (in the loop) or aka ThisRecord, aka _Child, then its just .KPI_Name etc
IF these values are in text boxes or labels or whatever then you would do
_Child.ControlName.PropertyToGrabValueFrom
ForAll(
gal_KPICategory.AllItems As _Parent,
ForAll(
_Parent.gal_KPIItems.AllItems As _Child,
Patch(
IDM_KPI_Responses,
Defaults(IDM_KPI_Responses),
{
Title: "Response", // Placeholder
Supplier_Name: varSelectedSupplier,
Category: _Parent.KPI_Category,
KPI_Name: _Child.KPI_Name,
Score: _Child.Score_Input
}
)
)
)
Another thing is you can simply validate that you are getting to the Child, even though the code is not correct, by doing this.
1. Update your code as such
ForAll(
gal_KPICategory.AllItems,
ForAll(
ThisRecord.gal_KPIItems.AllItems,
Trace("I am in the child loop and patch is next");
Patch(
IDM_KPI_Responses,
Defaults(IDM_KPI_Responses),
{
Title: "Response", // Placeholder
Supplier_Name: varSelectedSupplier,
Category: ThisRecord.KPI_Category,
KPI_Name: gal_KPIItems.Selected.KPI_Name,
Score: gal_KPIItems.Selected.Score_Input
}
)
)
)
Now, these Steps (Assumes you are in Dev Mode) NOT play made
1. Publish your App
2. Click the Stethescope
3. Click Live Monitor
4. Soon as Live Monitor Triggers
5. Run your code and make sure the changes above would be triggered
6. Go to Live Monitor Tab in browser
7. In Filter Type Trace
See if anything shows up. If NOT then you are not getting to the loop so no way to get data
If you are seeing them then do this next
8. Change filter to Error
See if you see errors, if nothing, thats fine, your code still technically shouldn't work correctly, I just wanted to show you how you could valdiate your code is being reached.
Make the changes per my code and directions on Controls and Properties and see if it works.
If Not, there is a platform known issue, where sometimes inner loops like this actually act like there is no data. So the AllItems for your child, will NOT do squat as it acts like there is nothing
To fix this we have to add something to the Parent (for instance, hide a label) in it put Text(CountRows(ThisItem.gal_KPIItems.AllItems))
And try again and if you all of a sudden see data then you have both issues (your code is incorrect) and the platform issue. Just fix one at a time.
If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.
Thank you!
Sincerely, Michael Gernaey