cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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 😉

 

View solution in original post

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 😉

 

View solution in original post

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
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 182 members 6,360 guests
Recent signins:
Please welcome our newest community members: