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.
Solved! Go to Solution.
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
Hi @Anonymous :
Do you want to display the number of remaining records that have not been added to the data source?
I’ve 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 can’t 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
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
User | Count |
---|---|
255 | |
114 | |
95 | |
48 | |
38 |