CategoryPower Apps

Easily validate Power Apps dates

In this post we’ll see how easily to validate date pickers in Power Apps. Right now am working on an application to help the IT team schedule the deployments for Office ProPlus (Microsoft 365 apps for enterprise) and Teams to users. I’d like to send an email to users asking them if the proposed date is good for them plus other questions that they can deal with in a Power Apps application, if not, they can reschedule. However, I want that when they reschedule for it to be at least 7 days from now so the IT team can have the time to prepare for the deployment and bundle multiple computers together. Also, I want to prevent users from choosing a weekend day. So how to do that? The formula for this would be too short and simple if we understand how to approach it.

First when we choose a date from the picker and click on the submit button, I will have a formula to update a context variable named “isValid”. What I’ll do is, to check if the difference between the selected data and today’s date is less than 7 days. I’ll do that with the DateDiff function, which acts like the following:

Second argument – First argument = Number of days.

This function will return the difference in days between the two dates, so we can check if it’s > 7. Note, this will also validate if the date is in the past as well, since if the date is less than today’s date, the result will be in the minus.

If it’s more than 7 days, we check for weekends. I will be using the Weekday function to determine if the selected date is equal to 1 (Sunday) or 7 (Saturday). To connect all the checks together so they’re all truthy, I’ll be using And operator between all checks, so the final formula would look like this:

UpdateContext({isValid: If((DateDiff(Today(), txtNewDate.SelectedDate, Days) > 7) And (Weekday(txtNewDate.SelectedDate) <> 1) And (Weekday(txtNewDate.SelectedDate) <> 7) , true , false)});       

Few handy functions here and there, to make powerful little formula.

Quick Tip – Power Apps on Android – “Pick an account to continue”

This one is going to be quick, but it took me a bit to figure it out. I am connecting to multiple Power Apps environments with the same phone across multiple tenants. Recently I started getting this issue whenever I open Power Apps on the phone I am returned to a screen showing me all my email accounts across tenants and it says: “Pick an account to continue”. When I choose an account, it shows the Apps list for a second, then it goes back to “Pick an account to continue” screen… which is frustrating.

I thought it’s an issue with Power Apps caching, so I deleted the cache. didn’t work… I deleted all Power Apps data, didn’t work. Then I found the best solution! Uninstall-Reinstall Power Apps… but yup that didn’t work either. How is Android remembering all these emails while I have been clearing the data all the time?

Turns out that this data is stored at this location: Settings > Users & Accounts > Work Account.

When I opened that screen, I saw all those junk emails sitting there and that’s where Power Apps mobile is reading the emails from. I cleaned up the emails and kept only the one I need.

Seems like Power Apps on Android doesn’t really handle multiple accounts that well. Since I tried later to add another account, it worked fine. Then I signed out of that account and tried in to sign in with another one, kept getting errors about “Sign in with work or school email is required”.

Best way I saw to solve this issue, is after signing out from a specific account with PowerApps, close the application, open it again and sign in with the new account.

Remember to clean up the accounts stored in your device, then have the habit of restarting the app after signing out.

In case you’re not working with multiple accounts in Power Apps, forget everything you read in this article!