PowerApps, Timer control

Build a Navigator App

What is a Navigator App?

I built a number of Power Apps that users often did not recal. Since they were also designed to run in a particular order, it was equally common that users might also skip one or more steps.

I created tabs in Teams to not only specify the apps but also showed the order. That left something to be desired:

  1. Too many tabs so that they all didn’t show at once
  2. Not much in the way of reminding them the run orer.

My Navigator Solution

Great, I thought, I will just create a Power App that lets users run apps by clicking on buttons but will show the order they should be run. Sounded pretty straightforward.

But then a few isses developed.

How do I get the app to run another app but return to the navigator app when exiting the referenced app? Turns out the solution was a series of things.

Steps to solve the issues

The place to start is the OnSelect propery of each button to run another app. The Power App function to use is Launch(). I used Launch() with three parameters:

  • The link to the target app;
  • The parameter to ue;
  • The destination tab/windown control

The link parameter could be one of tw forms: the https for the app or a specific app reference. Both of these can be found on the details page of the app as shown in this sample

I used the app ID and it was something like this:

Launch(“/providers/Microsoft.PowerApps/apps/<appID>”

Of course, substitue the actual app ID and make sure to use the exact string before it all in double qutes.

The next object in the expression is for parameters. I simply needed just a single paratemter that I could test in the app to determine if it had been lauched by the Navigator app or the user accessed it directly. I used the same parameter for all apps like this

{q: “Nav”}

Later I will ecplain why I pass a parameter and how to use it in the target apps.

The third and last value I set to LaunchTarget.Replace. This tells Navigator to use the same window to run the target app. The full expression is

Launch(“/providers/Microsoft.PowerApps/apps/20528f0f-c9fc-40e5-861a-<more…>”,{q: “Pick”}, LaunchTarget.Replace)

I then added a Exit(false) expreession.

Of Course This Didn’t Work Properly

I say of course but rest assured I thought it would. I wasn’t able to return to the Navgator app and see it reappear in the same browser tab.

After some testing, I came up with the following solution.

On a blank new sceen, I added a timer control. I set Duration to 3000 or 3 seconds. I set OnTimerEnd to Exit(false). I set Startto varTimer. Then I modified the OnSelect to be

Launch(“/providers/Microsoft.PowerApps/apps/20528f0f-c9fc-40e5-861a-<more…<“,{q: “Pick”}, LaunchTarget.Replace); Set(varTimer, true)

Modiying the Target Apps

Each target app required two changes:

  • In the App->Onstasrt, insert Set(varParam, Param(“q”))
  • In the app Exit or Quit button, insert

// If started from launcher, return to it else just exit
If(IsBlank(varParam),
Exit(),
Launch(“https://apps.powerapps.com/play/d16bb196-d5c5-4093-8bc8-9767408a4637?tenantId=b6904651<remainder…>&#8221;, {q:1}, LaunchTarget.Replace))

In other words, if no parameter were passed, the user executed the app directly, otherwise invokded by the Navigator. I used the url in this example but it could also have been the app ID format.

Works Great!

Now it all works as intended. Click on a button for a target app, the Navigator goes away and the target app appears in the same browser tab. Exit the app and the Navigator reappears in the same tab. Pretty fast aswell.

Except that….

Maybe yor recall Gilda Radner as Roseanne Roseannadanna on SNL. As she said, “It’s always something.” Imagine my surprise to hear from users that clicking on any of the app launch buttons did nothing at all. I tried debugging but it always seemed to work just fine. Then I found users having this problem were running Navigatorapp inside Teams since I had added that tab. And it’s true that nothing happens when it runs in Teams.

That seems to make sense.

blinking labels, PowerBI, Splash Screen, Timer control

When Only a Blinking Message Will Do

Why I Needed This

I developed a PowerApps for a client that is being used to submit sales and client outreach information. One of the fields is a sales amount, and far too often users fail to enter a decimal point. Instead of $1521.40, for example, the amount will be submitted as $152,140. Rarely are amounts on a report over $10,000.00, so I suggested that a warning message be displayed right next to the amount field.

Of course, over the next few days several were submitted over $10,000.00 and were incorrect. The users, who are used to just entering data, said they never saw the message.

Blink to the Rescue

The human brain is hard wired to detect movement and often doesn’t “see” static images, so blinking text is effective. And it’s simple to do. Here’s how.

  1. In app start, set a variable to false. I used varBlink.
  2. Create a timer control on your screen.
    1. Set Repeat to true.
    2. Set Start to determine the warning condition. For example, I used “If(Value)txtAmt)>10000, true, false)
    3. Set Duration to the blink rate; I used 500 for 1/2 second.
    4. Set OnTimerEnd to “Set(varBlink,!varBlink). This simply toggles the true/false value of the variable.
    5. Set Visible to false. You will want to hide this control.
  3. Create a label with Text set to the warning information. Set Visible on the label to varBlink.

What This Does

When the condition evaluates true, the timer starts. After the duration is complete, the value of the blink variable is swapped between true and false. The warning message displays when the variable is true and is not visible when it is false. Because this changes every half second (in this example), it displays for half a second then goes away for a half second. Because Repeat is set to true, the timer continues to run.

You can stop the timer by having the condition that started it change. In my case, if the amount field were edited to be smaller than $10,000.00, it stops automatically.

Other Things You Can Do

You can use other properties of the label to create more dramatic changes. For example, use the Color property to alternate between two colors using similar logic. Or change the Fill property, or change them both. You can’t accomplish this with the same variable because evry half second the warning disappears. Perhaps you can use a second time and variable where the duration is twice as long as the first, and start them at the same condition. You might also toggle a second variable whenever the warning becomes visible, an equivalent time.

Timer control, Uncategorized

Adding a Delay when Getting new records

The Situation

In my PowerApps, information about month-to-date sales is kept by location. In a SharePoint list, I maintain a record for each month and sales location that contains MTD sales, customer counts, number of items sold, etc. In another SP list, there is one record for each day for each sales location containing the daily sales, customer and item counts, and so on. When a daily record is added, the MTD record corresponding to the month and sales location is updated with the new daily totals.

The daily sales information is submitted via the PowerApps. When the user enters the daily sales, however, the app also shows a new MTD sales amount and, from the monthly record, shows the monthly and daily sales goals, then displays the amounts above or below those goals dynamically.

Each user has a default sales location as part of their contact information (I picked department). But in some cases, a user might enter daily sales information for another location. The app displays the “default” location at startup but allows the user to change from a drop down list (from another SP list…). When a new location is chosen, the app simply gets the new MTD record for that location using LOOKUP().

What Was Happening

Well, what was happening made no sense. If the user selected a new location, the MTD information continued to show the original location. Change it a second time, and the MTD information then showed data from the 1st change. And that would repeat no matter how many times the location was changed.

How I Diagnosed the Problem

After staring at the code for half a day and comparing it to the app startup code I could find nothing wrong. I added a label and displayed a value from the gallery that used the collection from the LookUp(), plus the variable that i set from that field. Sure enough, they were different, the former the new value (and what i could see if i looked at the collection) and the latter the original value. Still puzzled, i added a button to reset the variable from the gallery item. Magically, it got the right value. It took a few minutes to realize that it was a timing issue: I was setting the variables from the gallery items before the app had time to get the new record, so the variable just got the previous gallery value.

The Fix

Very simple.

  1. I inserted a timer control with a duration of 5 seconds.
  2. I pulled the code from the OnSelect from the drop down list on changing location and put that into the OnTimerEnd property. That’s after the ClearCollect() to get the MTD records.
  3. I tested and lo and behold the new values were perfectly set.
  4. I then went back to the timer control and reset the duration to 3 seconds and made the visible property false (users don’t need to see it).

In the OnSelect property from where i copied code already had a variable (varWait) to control the dislay of a wait message, so now it just appears for a short bit longer. You can check out my prior post on displaying wait messages with animated gif images.