cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Records remaining to patch

Hello, 

 

I have an app where supervisors report the hours for their crews. I place the records in a temporary Collection until they are ready to save everything. 

 

Then using ForAll(temporaryCollection) I patch each row to an Excel file. 
Sometimes there can be many rows in the collection which means the saving will take time. I would like to see a number counting down after each row is saved. 

I have tried to place Update Context within the ForAll function, but that is not possible it seems. Basically I see ForAll as a For loop from i =1 to number of Rows. I would like to know what the current i is and display on the screen so the user knows that progress of the saving. 

 

Thank you in advance for any advice. 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous :

Please try this solution

Step1:Add a button control

On Select:

 

Set(
    count1,
    CountRows(Table1) + CountRows(VarVarVar)
);
UpdateContext({Start: true}); /*my custom variable to start the timer*/
ForAll(
    VarVarVar,
    Patch(
        Table1,
        Defaults(Table1),
        {
            cust_id: cust_id,
            cust_name: cust_name,
            saler_name: saler_name
        }
    )
);
UpdateContext({Start: false}); /*stop timer*/
Set(
    count2,
    0
);

 

Step2:Add a timer control.

AutoStart: 

 

false

 

Duration: 

 

500  /*loop in 0.5s*/

 

OnTimerEnd:

 

Set(
    count2,  /* a variable used to record the number of remaining records that have not been added to the data source */
    count1 - CountRows(Table1)
)

 

Start:

 

Start /*my custom variable*/

 

Repeat: 

 

true

 

Visible:

 

false

 

Step3:Add a label control.

Text: 

 

count2

 

The label control will display the number of remaining records that have not been added to the data source.

Best Regards,

Bof

View solution in original post

3 REPLIES 3
v-bofeng-msft
Community Support
Community Support

Hi @Anonymous :

Do you want to display the number of remaining records that have not been added to the data source?

Ive made a test for your reference:

Step1:Add a button control

On Select:

Set(
    count1,   /* a variable used to record the number of rows of the table after the operation is completed */
    CountRows(Table1) + CountRows(VarVarVar)  /*Table1 is my data source, VarVarVar is the collection*/
);
Select(Timer1);
ForAll(
    VarVarVar,
    Patch(
        Table1,
        Defaults(Table1),
        {
            cust_id: cust_id,
            cust_name: cust_name,
            saler_name: saler_name
        }
    )
)

Step2:Add a timer control.

AutoStart: 

true

Duration: 

10  /*loop in 0.01s*/

OnTimerEnd:

Set(
    count2,  /* a variable used to record the number of remaining records that have not been added to the data source */
    count1 - CountRows(Table1)
)

Repeat: 

true

Visible:

false

Step3:Add a label control.

Text: 

count2

The label control will display the number of remaining records that have not been added to the data source.

In addition,since your data source is Excel, I suggest you pay attention to this following point(Main known limitations):

1\You can only edit the formatted table that in the Excel file. Format the Excel data as a table

2\If your Excel data includes a calculated column, you can't use it to build an app, and you cant add that data to an existing app.

3\Sharing Excel tables

In OneDrive for Business, share the file itself.

In OneDrive, share the folder that contains the file, and specify file paths, not URLs, for any media.

4\The maximum size of an Excel file that is supported by the Excel Online (OneDrive) connector is 5 MB.

5\An Excel file may be locked in OneDrive for an update or delete up to 12 minutes(OneDrive) since the last use of the connector.

6\You should not have the Excel workbook open in OneDrive when you are trying to update it, or you will receive the error The requested resource is locked.

 

Best Regards,

Bof

Anonymous
Not applicable

Hello Bof, 

 

Thank you for your help with my query. 

A few follow up questions. Since Timer1, AutoStart:true it will run from the moment the screen is visible. 
Will there be a performance impact from the call every 10 ms to CountRows of the Excel file? User may not click the save button for a awhile. 

What is point in code of Select(Timer1) if timer has already started on opening of the screen? 

 

Best regards, 

 

Erik  

Hi @Anonymous :

Please try this solution

Step1:Add a button control

On Select:

 

Set(
    count1,
    CountRows(Table1) + CountRows(VarVarVar)
);
UpdateContext({Start: true}); /*my custom variable to start the timer*/
ForAll(
    VarVarVar,
    Patch(
        Table1,
        Defaults(Table1),
        {
            cust_id: cust_id,
            cust_name: cust_name,
            saler_name: saler_name
        }
    )
);
UpdateContext({Start: false}); /*stop timer*/
Set(
    count2,
    0
);

 

Step2:Add a timer control.

AutoStart: 

 

false

 

Duration: 

 

500  /*loop in 0.5s*/

 

OnTimerEnd:

 

Set(
    count2,  /* a variable used to record the number of remaining records that have not been added to the data source */
    count1 - CountRows(Table1)
)

 

Start:

 

Start /*my custom variable*/

 

Repeat: 

 

true

 

Visible:

 

false

 

Step3:Add a label control.

Text: 

 

count2

 

The label control will display the number of remaining records that have not been added to the data source.

Best Regards,

Bof

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
Top Kudoed Authors
Users online (5,306)