BackupCheck



In some circumstances, updating the data underneath a user would be disorienting. Instead you could notify them that new data exists, and let them chose when to refresh.

This blog is intended to show you a technique for doing so.

Demo Specifics:

Example: An employer is running a town hall and wants employees to submit their questions in a way that other employees can read them, and up-vote them. This allows the questions to be crowd sourced to determine which questions the employer should address at the end of the presentation.
This solution allows users to be notified that they can refresh to see new questions. This option rather than having the data update beneath them and shift while they are scrolled and reading.

Back End Used: SPO List

However, there are also issues with your conditionals. It looks like your first 2 conditionals are meant to only test whether the enclosed command succeeds or not. Generally, you do not need. for such tests at all, and instead simply use the command directly with if, possibly negated with!, and with output suppressed as needed with /dev/null or 2/dev/null.

End Product: Point of interest with this blog is the refresh icon shown in the red box.

Toast Wallet Backup Checker. This is a client side script to check your backup for errors. You may need to use this if you printed and scanned a Toast Wallet backup code. The Backup Check queries the device on the selected days to determine the status of the backup, ensuring that in the event of any problems on the client’s server there is a backup to restore from. The Check looks back over the previous 24 hours and failures where. Jul 17, 2017 I called mine backupCheck — Make it run — Duration: 30000 //to refresh the backup every 30 seconds. Repeat: True //this allows the timer to loop over and over. AutoStart: True //to have the timer start when the screen becomes visible — Make it hidden — Visible: false. This is a client side script to check your backup for errors. You may need to use this if you printed and scanned a Toast Wallet backup code. This script will report errors to you using the checksum. It will also regenerate the leading checksum for you if no errors are found in the rest of the code.

Steps at a high level:

  1. Add a second connector to your Data Source
  2. Add a timer which updates your secondary copy on a fixed cadence
  3. Add to that logic, comparison logic to see if your data source changed
  4. Add UI which is shown only when that comparison logic indicates that new data exists

Step 1: Add a second connector to your Data Source

The steps are the same as creating the first connection, please see the following blog for details: https://powerapps.microsoft.com/en-us/tutorials/add-data-connection/

Once you add a second connection to your data, you will see something like the following under your data sources.

Step 2: Add a timer which updates your secondary copy on a fixed cadence

Timers are controls you can use you make things happen on a cadence, or generally to make the app do something at the end of the timer.

Backup Checklist

For verbose information about timers, please see this blog: https://powerapps.microsoft.com/en-us/tutorials/control-timer/

Timers have to be on the active screen in order to run, so you cant hide them away on other screens. But they don’t have to be visible.

Below are the settings used for our timer:

— Name your timer —

Its good to name all your controls so they are easily found/used later.

Backup Check Register

I called mine backupCheck

— Make it run —

BackupCheck

Duration: 30000 //to refresh the backup every 30 seconds

Repeat: True //this allows the timer to loop over and over

AutoStart: True //to have the timer start when the screen becomes visible

— Make it hidden —

Visible: false

X: 0

Y: 0

Width: 0

Height: 0

Tip: I like to make non-visible things 0 on size and placement vectors as well, so that they don’t interfere with design time selection

Tip: You can watch the timer for your testing even with the timer hidden by looking at the Properties pane on the right, while the timer is selected

— Make it update the secondary connector for your data source —

On timer End: Refresh(QnA_1)

Step 3: Add to that logic, comparison logic to see if your data source changed

So now we have the timer hidden and running, updating the second data copy.

Now lets add the logic to compare the two copies of the data and see if something updated.

In my example, I expect to only have additive items, so my logic simply compares count. You may require more complex comparison logic.

— at the load time of the screen, set up the data sources and variables

We will use Global Variables for measuring if new data exists.

This means setting the values when we are ready to check, they wont update automatically like the rest of the values in the PA which are model based

(for more information about the model based approach of PA see Deep Dive on Functions)

Backup checkpoint

(for more information about global variables see https://powerapps.microsoft.com/en-us/tutorials/working-with-variables/)

— setup on load–

onVisible:

Refresh(QnA); Refresh(QnA_1); Set(Count_Questions, CountRows(Filter(QnA, isApprovedText=”Yes”))); Set(Count_Backup, CountRows(Filter(QnA_1, isApprovedText=”Yes”))); Set(Count_Diff, Abs(Count_Backup-Count_Questions))

–check it out —

You can view your variable values in the file menu as shown here. At this point, because you have just refreshed both, you should have Count_Diff = 0

Backup Checking

–augment timer to update the variables–

On timer End: Refresh(QnA_1); Set(Count_Backup, CountRows(Filter(QnA_1, isApprovedText=”Yes”))); Set(Count_Diff, Abs(Count_Backup-Count_Questions))

You’ve done it! Except you would only know that by looking at the variables page. To show to the user, finish with step 4.

Step 4: Add UI which is shown only when that comparison logic indicates that new data exists

— Add your UI —

I have a circle (called diffCircle) and a text box (called diffText)

I also have a refresh icon (called refreshIcon) underneath these two objects

— Make them only visible when there is a diff (be sure set for both the circle and the text objects) —

Visible: If(Count_Diff<=0, false, true)

— Make the text of the text box (diffText) show the number —

Backup Check

Text: If(Count_Diff<9, Count_Diff, “9+”)

Backup Checklist Template Excel

— Reset these values when the user hits refresh (refreshIcon) after refresh —

Backup Checkpoint Firewall

OnSelect: Refresh(QnA); Refresh(QnA_1); Set(Count_Questions, CountRows(Filter(QnA, isApprovedText=”Yes”))); Set(Count_Backup, CountRows(Filter(QnA_1, isApprovedText=”Yes”))); Set(Count_Diff, Abs(Count_Backup-Count_Questions))

That’s It!

I hope this was helpful for you.