Hello!
I'm trying to create a form page which inserts multiple rows into a Sharepoint list. Based on which Business Unit the user chooses, the number of regions in the form changes. One region equals 4 fields. For example, one BU may have 3 regions x 4 fields, another may have 10 regions x 4 fields.
I want to loop these based on the information about the BU available in a Sharepoint list, although it seems impossible to do so in a simple form.
I've tried to use a gallery to loop the regions, then insert 4 text inputs per region. The save button uses a ForAll() and a Patch() to insert the inputs into the Sharepoint list. This solution doesn't work.
ForAll(Gallery1.AllItems; Patch('Weekly Report'; Defaults('Weekly Report');{ 'Value1':TextInput1; 'Value2':TextInput2; 'Value3':TextInput3; 'Value4':TextInput4; 'WeekNum':Dropdown1; 'Business Unit':Label1 } ) );;
Can you help me find a solution to this?
Many thanks!
I'm not clear on exactly what you're doing but could it be as simple as that you need to use "TextInput1.Text" and "DropDown1.Selected.Value" etc.?
I have already tried this without success, unfortunately. But thanks for the help.
You need to specify the properties for those controls as @sopatte mentioned.
Your formula would be this:
ForAll(Gallery1.AllItems; Patch('Weekly Report'; Defaults('Weekly Report');{ 'Value1':TextInput1.Text; 'Value2':TextInput2.Text; 'Value3':TextInput3.Text; 'Value4':TextInput4.Text; 'WeekNum': Dropdown1.Selected.Value; 'Business Unit':Label1.Text } ) );;
If you are having some sort of error appear or other issue, please post back.
I hope this is helpful.
Oh, I just figured out that TextInput1, TextInput2, etc. are all controls in the gallery and you're trying to iterate through the gallery items and get the value from the controls which are repeated.
I've never seen that before, but it might work if you use the field names instead of the control names. So if TextInput1 is connected to Field1, you might try substituting Field1 for TextInput1 in your code.
Yes, that does work and is intended. If you have a control in the gallery, it becomes part of the record of the AllItems.
So in the case of @Erimar the syntax is correct if the intention is to gather the values of the controls in the gallery associated with the item.