cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WI-User-01
Level: Powered On

Issue with Submit Form and Patch Repeating Gallery via OnSuccess

I'm following Shane Young's YouTube guide on using custom forms to look like InfoPath and am running into a hiccup. @Shanescows

 

Source:  https://youtu.be/5vVFgaEBYuM

I've got the form and the gallery working just fine and I'm using the OnSuccess of the Form to patch the repeating Gallery to my SQL database. 

What's happening is this...  If there is more than 1 entry in the gallery, the data writes properly to the collection I save it to.  View Collections shows accurate data.  When the OnSuccess patches the collection to the SQL database, the first record in the collection is repeated into SQL, instead of the actual data being written.

 

Here's an overview:

1. App loads, Form autopopulates with user and a unique request number (working fine)

2. Gallery has a bunch of fields and a save button.  Clicking the save button saves the item to a collection.  Each time they click Save, it saves that item to the collection (working fine)

3. User clicks the Submit button to submit the data they've just entered in.  If they've only entered 1 item, all is well.  data in form and data in Gallery/Collection is written just fine.  If they've entered more than 1 item into the Gallery, only the first item in the collection is written, but, if there are 5 items, the first item's data is written 5 times to SQL.  (not working)

 

 

Here's a snippet of my patch code in the OnSuccess...  I've edited it for privacy, but that's the jist of it.  The bold parts were changed from actual names to general names.

ForAll(Collection, Patch('[SQL Table]', Defaults('[SQL Table]'), {List of about 15 fields}));Clear(Collection)

 

Any ideas where my glitch is?  

 

1 ACCEPTED SOLUTION

Accepted Solutions
WI-User-01
Level: Powered On

Re: Issue with Submit Form and Patch Repeating Gallery via OnSuccess

Good news!

I figured out my own issue after a day or so of going over it...

 

In my OnSuccess code, specifically, the list of 15+ fields I am patching to SQL, I was referencing the Gallery input fields, instead of the Collection field names.  Once I realized that and changed the field names in the code to reference the right data, it is now working great.

 

Thought I'd come back and update the post in case anyone else experiences this too.  Have a good day.

2 REPLIES 2
WI-User-01
Level: Powered On

Re: Issue with Submit Form and Patch Repeating Gallery via OnSuccess

Good news!

I figured out my own issue after a day or so of going over it...

 

In my OnSuccess code, specifically, the list of 15+ fields I am patching to SQL, I was referencing the Gallery input fields, instead of the Collection field names.  Once I realized that and changed the field names in the code to reference the right data, it is now working great.

 

Thought I'd come back and update the post in case anyone else experiences this too.  Have a good day.

Super User
Super User

Re: Issue with Submit Form and Patch Repeating Gallery via OnSuccess

Glad you got it. Sorry, I was slow to respond. 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 262 members 4,471 guests
Please welcome our newest community members: