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

Collection Bulk Insert SQL - Ideas?

Greetings!

 

I would appreciate if you can guide me on achieving the following. I am new to PowerApps and I have seen posts about Flow, but am not able to implement - so any step by step directions will be greatly appreciated.

 

I am using barcode scanner to continuously scan and store the scanned values to a collection in PowerApps. I want to (in the background, while continuing to scan) save the collection into SQL table. Once saved, clear the collection and continue. I think a timer control may be able to help and I have seen that I may have to use Flow. Can I have a timer control on a different screen than the scanner screen and have it run periodically to save data to SQL? How would I go about this?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
kylzbaba
Resolver I
Resolver I

Yes SqlList means SQL table.

 

Yes you can have a timer, set the ontimeend property to run the patch and clear the collection. But this isn't necessary, just have a button they can click on when they are done. The bulk update will work beautifully. Also you can set a counter that when it hits a value like maybe 50, it's forces the user to save the details already collected. Also remember to clear after patching to avoid duplicates. 

 

 

Please if this answes your question, accept as a solution.

View solution in original post

5 REPLIES 5
EdViegas
Super User
Super User

Why not save directly to SQL and show in your Gallery the latest SQL records?

mrathi
Frequent Visitor

Hi, the reason is the scanner will continuously scan and I read that it may slow down the process if I keep adding 1 record at a time to SQL. Also, if the connection is interrupted, I can at least have offline scans in a collection that can save to SQL when the connection is online. Thanks

kylzbaba
Resolver I
Resolver I

Yes you can. 

Make sure the datatype of the collection items match the data type of corresponding field in sql. Also the names should match.

 

So if you have Name field with datatype text in sql, then the collection should be {Name:""}

 

Once the collection is done you can simple patch using the statement

 

Patch(sqlList, collection) and it will bulk update. Create new records. 

 

 

https://www.matthewdevaney.com/power-apps-excel-style-editable-table-part-1/

 

Matthew does a good explanation here.

mrathi
Frequent Visitor

Thank you. I am assuming sqlList is the SQL table name? Also, do you know if I can have a timer on another screen that can periodically call the Patch? If so, please advise on how.

kylzbaba
Resolver I
Resolver I

Yes SqlList means SQL table.

 

Yes you can have a timer, set the ontimeend property to run the patch and clear the collection. But this isn't necessary, just have a button they can click on when they are done. The bulk update will work beautifully. Also you can set a counter that when it hits a value like maybe 50, it's forces the user to save the details already collected. Also remember to clear after patching to avoid duplicates. 

 

 

Please if this answes your question, accept as a solution.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,486)