cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Migrated_User
Level 10

PATCH a collection

Content migrated from TechNet.  Post attribution to:  Brian Dang

Hi,

 

I'm developing a game on PowerApps. The game requires the player to respond to a problem, then click a "next" button to save their input, collect other data, and advance to a new problem. The "next" button uses the PATCH function to create a new row of data on a spreadsheet located on Dropbox.

 

My problem is that when the player clicks the next button to PATCH, there is a noticeable 3-5s delay before the app responds. I tested very basic PATCH functions on an almost blank app and it responds with the same delay. Given that my app is a game of speed, I am wondering if there is a way to minimize the instances of PATCH.

 

For instance, since the player must PATCH every single round, it slows things down. If they only needed to PATCH at the conclusion of their play, I think I can make my game more viable. Would it be possible to program PATCH to create all the records from a collection into a target spreadsheet in one move? Or is there an alternative that already exists for patching more than one record at a time?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Migrated_User
Level 10

Re: PATCH a collection

Hi

Each time when you press the PATCH button, it can only push to row of record.

 

So, you can set a Timer, with desired duration, say 500ms on TimerEnd, to automatically PATCH data into Excel file. You may have another Button to stop or another Timer to set the total time to patch (Timer2/Timer1 = no of times to patch as you wish).

 

Hope this help.

 

TQ


PK Hong

View solution in original post

Migrated_User
Level 10

Re: PATCH a collection

I made a temporary solution. It is quite a work-around. It uses concepts from a basic calculator app.

 

Suppose I want to write name, date and ID to back to a database. Normally, I would use Patch one row at a time:

Patch(ExcelDatabase,Defaults(ExcelDatabase),{Name: name.text, Date: date.text, ID: id.text})

 

Instead, I now use 2 variables for each column that I want to patch. I use UpdateContext to create a concatenated string with Char(10) for carriage return. Then I do a single patch of those long strands.

Set a button equal to:

UpdateContext({Name2: name.text, Date2: date.text, ID2: id.text});
UpdateContext({Name1: Name1 & Char(10) & Name2 & Char(10), Date1: Date1 & Char(10) Date2 & Char(10), ID1: ID1 & Char(10) & ID2 & Char(10)})

Then I do a single patch:

Patch(ExcelDatabase,Defaults(ExcelDatabase),{Name: Name1, Date: Date1, ID: ID1})

The data is inflexible, but if it is looked at at few intervals like I will be doing, it is a fair temporary solution.

View solution in original post

10 REPLIES 10
Migrated_User
Level 10

Re: PATCH a collection

Hi Brian:

 

Please refer to the sample apps I sent to you days before.

1. If the Textbox or other properties used to collect data, and reside in "Card Gallery", then each TextBox can be written as {Text1: TextBox1.Text, Text2: TextBox2.Text,...} assuming Text1, Text2,.. are the title of your table. Then use Cardgallery.Update when patching. This will PATCH by Cardgallery.

and if you have more than one CardGallery, then all of them can be patched using Gallery.Updates,if all the Cardgalleries are inside the Infinite Scrolling Layout.

Take Note:

1. Cardgallery.Update (without s)

2. Gallery.Updates (with s)

This will PATCH all records with a single click.

Hope this helps.

 


PK Hong

Migrated_User
Level 10

Re: PATCH a collection

Hi Brian

While you waiting for an answer... did you know that you will not be able to share your game with the world because powerapps doesn't allow that and never will?

 

Sorry for that.. I'm just trying to save you a time in case you don't know that 

Migrated_User
Level 10

Re: PATCH a collection

@PK, I copied some elements from your sample app that had name and qty. 

 

Can you explain what the Defaults function does? I think if I understand that, PATCH will make a little more sense to me.

 

@ Ptr.Chovan, That is a missed opportunity for PowerApps. Luckily, I mostly plan on using these apps within my own classroom, so in the short-term I will be self-sufficient with just my account.

Migrated_User
Level 10

Re: PATCH a collection

Hi

Defaults(TableData) = Create a New Records (Row) in this existing TableData.

 

Please read this Part. Very Important. I spent several hours to digest and it really worth the hours. Most of the concept of MS Samples is based on this one. I would say every sections in Help worth reading. I had read all for several time.

 

796733.png

PK Hong

Migrated_User
Level 10

Re: PATCH a collection

I summarized the process in a flow map. I am unsure how Patch can write an entire collection to the ExcelDatabase though. It seems to only do one row. Can you clarify how I can write more than one row per click?

 

796749.png

Migrated_User
Level 10

Re: PATCH a collection

Hi

Each time when you press the PATCH button, it can only push to row of record.

 

So, you can set a Timer, with desired duration, say 500ms on TimerEnd, to automatically PATCH data into Excel file. You may have another Button to stop or another Timer to set the total time to patch (Timer2/Timer1 = no of times to patch as you wish).

 

Hope this help.

 

TQ


PK Hong

View solution in original post

Migrated_User
Level 10

Re: PATCH a collection

Thank you for the help, PK. I sent back feedback on patching more at a time.

Migrated_User
Level 10

Re: PATCH a collection

I made a temporary solution. It is quite a work-around. It uses concepts from a basic calculator app.

 

Suppose I want to write name, date and ID to back to a database. Normally, I would use Patch one row at a time:

Patch(ExcelDatabase,Defaults(ExcelDatabase),{Name: name.text, Date: date.text, ID: id.text})

 

Instead, I now use 2 variables for each column that I want to patch. I use UpdateContext to create a concatenated string with Char(10) for carriage return. Then I do a single patch of those long strands.

Set a button equal to:

UpdateContext({Name2: name.text, Date2: date.text, ID2: id.text});
UpdateContext({Name1: Name1 & Char(10) & Name2 & Char(10), Date1: Date1 & Char(10) Date2 & Char(10), ID1: ID1 & Char(10) & ID2 & Char(10)})

Then I do a single patch:

Patch(ExcelDatabase,Defaults(ExcelDatabase),{Name: Name1, Date: Date1, ID: ID1})

The data is inflexible, but if it is looked at at few intervals like I will be doing, it is a fair temporary solution.

View solution in original post

Migrated_User
Level 10

Re: PATCH a collection

Wow, you got an excellent idea. I shall try it, too, to PATCH 2-records or more at a time.

Thanks Brian.


PK Hong

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: 164 members 6,187 guests
Please welcome our newest community members: