Announcements
I’ve been stuck on this for the past seven days and would really appreciate your help.
I need to update multiple rows in a SQL table directly from a Power Apps gallery. Each gallery item contains three ComboBox controls and three TextInput controls. I’m looking for the correct approach (and formula) to save all edited items in the gallery back to SQL in one go.
If your SQL column name contains spaces, make sure to wrap it in single quotes while patching.
ForAll( colAllChannel As r, Patch( 'GPS.sql_channel', LookUp('GPS.sql_channel', ID = r.ID), { 'Textinput 1': Value(r.'Textinput 1'), 'Textinput 2':Value(r.'Textinput 2') } ) )
If the above solution still doesn’t work, please share a screenshot of your collection output, your SQL table structure, and the exact error message you are getting. That information will help us troubleshoot the issue further and give you a more accurate solution.
Hope this helps 👍
It looks like the logic is correct. However, when using a SQL data source, make sure the table has a primary column. otherwise, Power Apps won’t support write operations like Patch/update.
ForAll( colAllChannel As r, Patch( 'GPS.sql_channel', Defaults('GPS.sql_channel'), { 'Textinput 1': Value(r.'Textinput 1'), 'Textinput 2':Value(r.'Textinput 2') } ) )
Please note that these two columns are Number columns only, so the code looks correct.
Could you please share the error screenshot? That will help us troubleshoot the issue and provide an appropriate solution.
ForAll( Gallery.AllItems As r, //Replace - Gallery control name with your gallery name Patch( 'GPS.fct_tapp_wip_channel', LookUp('GPS.fct_tapp_wip_channel', ID = r.ID), { Tgt_TDP: Value(r.TextInput_TDP.Text), //Replace - TextInput_TDP with your text field name from gallery Tgt_HEL:Value(r.TextInput_HEL.Text) //Replace - TextInput_HEL with your text field name from gallery } )
Thanks for updating me.
The last error says that the record you are trying to update does not exist in the table. Could you please verify if this record exists in the table?
Regarding the update taking more time, it is because we are trying to update all the records that are in the gallery. That’s why it is taking some time, it is attempting to update all 60 records.
In this case, we need to use a collection to store only the data that we want to update. This way, if the gallery shows 60 records but you are updating only 10, it will update only these 10 records.
On the Change property of all TextInput/dropdown controls (Input Property), write the code accordingly.
If(IsBlank(LookUp(col_updatedChannel,ID=ThisItem.ID)), Collect(col_updatedChannel, { GCC_CHANNEL_L1_NAME:r.ch_channel.Selected.Value, GCC_CHANNEL_L1_CODE:r.ch_channel_id.Text, Tgt_TDP: Value(r.ch_tdp_tgt.Text), Tgt_HEL:Value(r.ch_sos_tgt.Text), Tgt_SOS:Value(r.ch_sos_tgt.Text), ID:ThisItem.ID } ), Patch(col_updatedChannel, {ID:ThisItemID}, { GCC_CHANNEL_L1_NAME:r.ch_channel.Selected.Value, GCC_CHANNEL_L1_CODE:r.ch_channel_id.Text, Tgt_TDP: Value(r.ch_tdp_tgt.Text), Tgt_HEL:Value(r.ch_sos_tgt.Text), Tgt_SOS:Value(r.ch_sos_tgt.Text) } ) );
ForAll( col_updatedChannel As r, Patch( 'GPS.fct_tapp_wip_channel', LookUp('GPS.fct_tapp_wip_channel', ID = r.ID), { GCC_CHANNEL_L1_NAME:r.GCC_CHANNEL_L1_NAME, GCC_CHANNEL_L1_CODE:r.GCC_CHANNEL_L1_CODE, Tgt_TDP: Value(r.Tgt_TDP), Tgt_HEL:Value(r.Tgt_HEL), Tgt_SOS:Value(r.Tgt_SOS) } ) ); Clear(col_updatedChannel);
colAllChannel
Clear(col_updatedChannel);
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Jump in, show your community spirit, and win prizes!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Valantis 424
WarrenBelz 355 Most Valuable Professional
11manish 290