Hi I'm trying to Patch Collection created through Collect to SharePoint list but it keeps saving the only first record from Collection, code as follows;
ForAll(FishCatchCollection, Patch('Daily Fish Catch Detail', Defaults('Daily Fish Catch Detail'), {'Vessel Name': TextInput_VesselName.Text, 'Vessel Type': DD_VesselType.Selected, Guest: DD_Guest.Selected, 'Captain Name': TextInput_Captain.Text, Hail: Value(TextInput_Hail.Text), Unload: Value(TextInput_Unload.Text), 'In / Out': DD_InOut.Selected, Reason: DD_Reason.Selected, Comment: TextInput_Comment.Text}))
I attached PowerApps Screen and SharePoint list entry, as you can see PowerApps Collection have different records, on the other hand, SharePoint list only saving the first record and loop it as many times as the collection records are.
Please advise
Solved! Go to Solution.
I am assuming that all of the referenced controls (like TextInput_VesselName) are part of your Gallery.
If that is the case, then referencing them in the way you are in your patch is going to only give you the first instance (record 1 in your case).
You need to reference the Controls as part of the Gallery:
ForAll( YouGalleryName.AllItems, Patch('Daily Fish Catch Detail', Defaults('Daily Fish Catch Detail'), {'Vessel Name': TextInput_VesselName.Text, 'Vessel Type': DD_VesselType.Selected, Guest: DD_Guest.Selected, 'Captain Name': TextInput_Captain.Text, Hail: Value(TextInput_Hail.Text), Unload: Value(TextInput_Unload.Text), 'In / Out': DD_InOut.Selected, Reason: DD_Reason.Selected, Comment: TextInput_Comment.Text}))
This will go through each item in your Gallery and patch it to the SharePoint list.
I hope this is helpful for you.
I am assuming that all of the referenced controls (like TextInput_VesselName) are part of your Gallery.
If that is the case, then referencing them in the way you are in your patch is going to only give you the first instance (record 1 in your case).
You need to reference the Controls as part of the Gallery:
ForAll( YouGalleryName.AllItems, Patch('Daily Fish Catch Detail', Defaults('Daily Fish Catch Detail'), {'Vessel Name': TextInput_VesselName.Text, 'Vessel Type': DD_VesselType.Selected, Guest: DD_Guest.Selected, 'Captain Name': TextInput_Captain.Text, Hail: Value(TextInput_Hail.Text), Unload: Value(TextInput_Unload.Text), 'In / Out': DD_InOut.Selected, Reason: DD_Reason.Selected, Comment: TextInput_Comment.Text}))
This will go through each item in your Gallery and patch it to the SharePoint list.
I hope this is helpful for you.
Love it @RandyHayes, thank you!
Just tried it, work like a magic 🙂
Yes, all referenced controls (like TextInput_VesselName) are part of Gallery - true.
This is NOT working anymore!
Is there anything more to that statement?
I found that the "yourGalleryName.AllItems" does not work for me.
YouGalleryName.AllItems
Instead the following works fine.
ForAll( YouGalleryName, Patch('SP List Name', Defaults('Sp List Name'), {'Column Name': LineColumnName, 'Column Name2': LineColumnName2 }))
LineColumn name is referred to the Column default value.
Cheers,
Alaleh
@Anonymous
You cannot iterate a ForAll over a control. It needs a table source. AllItems is a table source on a Gallery.
Hi @RandyHayes ,
I agree with you, I use the different method which the result would be the same ae "Gallary.AllItems" . The All items, didn't work for me.
First for adding the repeating table row, I use the
BTN: OnSelect : Collect ( Collection Name,{ LineName:"",LineName2:""})
Second I save each row of gallery to collection
in Gallery for the column I add the "ThisItem.LineName" to default property
Then create the Save an on select: Patch( collection Name,ThisItem,{LineName:TextInput.Text,LineName2:TextInput2.text})
then submit all the rows into list by click submit
Submit: For All(Collection Name,Patch(SPList Name,Defaults(SP List Name),{Column name in list:LineName,Column Name2:LineName2})
In this way after the submit all the rows will save in the list all in once.
Cheers,
Alale
@Anonymous
Yes, and you can avoid all that work and just simply use a formula like this:
ForAll(
yourGallery.AllItems,
Patch(SPLListName, Defaults(SPListName),
{ColumnNameInList : TextInput.Text,
ColumnName2 : TextInput2.Text
}
)
)
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
User | Count |
---|---|
164 | |
94 | |
64 | |
63 | |
61 |
User | Count |
---|---|
236 | |
162 | |
95 | |
83 | |
81 |