cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
henrychr
Level: Powered On

Collections and Stored Procedure writeback

Hi,

 

I have an intake form in PowerApps, where the user can enter some information, and it's written to our SQL table using a stored procedure. Right now they have to enter each record one at a time. So if for example the end user is recording some stuff from a tradeshow, they'd enter the show name, date, and the name of the lead.

 

But if they got like 10 leads from the same trade show, I want to allow them to enter the name of the leads into a collection, and write that back to SQL as separate entries.

 

Collect(cLeads,comboboxLeadName.SelectedItems.Value)
;UpdateContext({vShow:txtShow.Text, vDate:dtShowDatePicker.SelectedDate})
;StoredProcedure.Run(vShow,vDate, cLeads)

where it would write the same show and date for however many leads are stored in the cLeads collection.

 

I was hoping for a way to do it with ForAll to step through each item of the collection, but I'm not sure this is the right function? Any hints?

1 ACCEPTED SOLUTION

Accepted Solutions
Dawidvh
Level 10

Re: Collections and Stored Procedure writeback

Hi @henrychr 

 

Would you only like to send lead names, or is there additional information about the leads that you want to submit. Is there a specific reason you are using a stored proc at the moment, and not just writing the data directly to the table from PowerApps?

 

If you do a ForAll it will issue 10 instructions to SQL which might not be ideal, depending on how many records you might have in total, as well as the upload speed and SQL server performance.

 

You could send the stored proc a string separated list though flow which will in all likelyhood be the fastest, but the most tricky to setup.

 

Another options would be to do just to a Collect(sqlTableName,localCollectionName) if the columns are exactly the same.

 

Let me know if you don't come right.

 

Dawid van Heerden
Follow on Twitter: @davestechtips
Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1
**If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions. AND we get points for it Smiley Wink

 

2 REPLIES 2
Dawidvh
Level 10

Re: Collections and Stored Procedure writeback

Hi @henrychr 

 

Would you only like to send lead names, or is there additional information about the leads that you want to submit. Is there a specific reason you are using a stored proc at the moment, and not just writing the data directly to the table from PowerApps?

 

If you do a ForAll it will issue 10 instructions to SQL which might not be ideal, depending on how many records you might have in total, as well as the upload speed and SQL server performance.

 

You could send the stored proc a string separated list though flow which will in all likelyhood be the fastest, but the most tricky to setup.

 

Another options would be to do just to a Collect(sqlTableName,localCollectionName) if the columns are exactly the same.

 

Let me know if you don't come right.

 

Dawid van Heerden
Follow on Twitter: @davestechtips
Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1
**If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions. AND we get points for it Smiley Wink

 

henrychr
Level: Powered On

Re: Collections and Stored Procedure writeback

We weren't using Patch because the table was set up incorrectly, but I fixed it! Someone didn't enable the primary key.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

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: 429 members 4,920 guests
Please welcome our newest community members: