cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
henrychr
Frequent Visitor

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
DavesTechTips
Super User
Super User

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
DavesTechTips
Super User
Super User

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 😉

 

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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (3,450)