cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AnthonyPhan
Level 8

Detect web browser users

Hi All,

I understand that the SaveData data and Load data funcations are currently only supported on studio and moble. I would like to detect whether users are studio or mobile so I can avoid these functions when using the web browser. How can i go about doing this.

Currently im using this but it isnt really working.

Set(IsBrowser, !IsEmpty(Errors(SaveData(testCollection, "TestSave")))) 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff claudiosvcc
PowerApps Staff

Re: Detect web browser users

From what I'm seeing here that's happening because SaveData does not return an error, so your logic would be broken.

I'm not sure if there's a best approach, but you can get unblocked with this:


Set(IsSaveDataSupported, !(CountRows(SaveData(["1", "2"],"myTestList").Value)=2))

 

I've put this on first screen's OnStart and that worked fine.

Hope it helps

 

Please, keep in mind that SaveData might change its behavior in the future (e.g., to return an Error). 

11 REPLIES 11
PowerApps Staff claudiosvcc
PowerApps Staff

Re: Detect web browser users

From what I'm seeing here that's happening because SaveData does not return an error, so your logic would be broken.

I'm not sure if there's a best approach, but you can get unblocked with this:


Set(IsSaveDataSupported, !(CountRows(SaveData(["1", "2"],"myTestList").Value)=2))

 

I've put this on first screen's OnStart and that worked fine.

Hope it helps

 

Please, keep in mind that SaveData might change its behavior in the future (e.g., to return an Error). 

mr-dang
Level 10

Re: Detect web browser users

This is going to help me out a lot!

 

Can I get a clarification though, @claudiosvcc.

 

Set(IsSaveDataSupported, !(CountRows(SaveData(["1", "2"],"myTestList").Value)=2))

If I understand correctly, this means, "Check if myTestList returns 2 rows. If SaveData returns 2, the ! in red means take the opposite of that, so the variable returns false. If it doesn't return 2, the ! causes the variable to return true." I assume @AnthonyPhan wants the variable to return true if SaveData does not work, so this makes sense.

 

I am confused because with the NOT (!), the name of the variable may be mismatched. Would the variable be more appropriately named something like "IsSaveDataNotSupported"? Or did I misunderstand the formula logic?

 

Microsoft Employee
@8bitclassroom
AnthonyPhan
Level 8

Re: Detect web browser users

Hi @mr-dang

Your understanding of the logic is correct. The variable could be better named as "IsSaveDataNotSupported".

 

@claudiosvcc Another thing worth mentioning is on start you will recieve an error message in web browser mode. Is there any way to hide this to improve the user experience for the browser users?

image.png

FredTherrien
Level: Powered On

Re: Detect web browser users

@claudiosvcc I have the same issue. Is it possible to hide this error message? 

 

Thanks

AnthonyPhan
Level 8

Re: Detect web browser users

Hi @FredTherrien

I found that for my purposes checking if there are any accelerometer readings was a work around. Within my organisation all mobile devices had accelerometers and all desktop device did not. By checking this instead of saveData I was able to throw no error and accuratly differentiate between devices

 

Set(IsSaveDataSupported, !IsBlank(Acceleration.X));
PowerApps Staff claudiosvcc
PowerApps Staff

Re: Detect web browser users

You're right.

I think I was using locally IsBrowser and renamed it.

Sorry for that

FredTherrien
Level: Powered On

Re: Detect web browser users

Thanks @AnthonyPhan this is a great workaround!

Highlighted
keathley
Level: Powered On

Re: Detect web browser users

For anyone else that comes across this thread and is looking to use @AnthonyPhan's suggestion (many thanks Anthony), I ran into an issue (maybe its with the latest version) whereas:

 

Set(IsSaveDataSupported, !IsBlank(Acceleration.X))

occasionally sets IsSaveDataSupported = false on my mobile device when the formula is set on the OnStart function of the first screen of the app.  I actually found it inconsistent with each open of the app it may be true or it may be false seemingly randomly.  However, when I put a (500ms AutoStart AutoPause) Timer on the first screen, and set the OnTimerEnd function to the same formula it consistently returns true on my mobile and false on the web (as expected).  It appears that Acceleration.X is sometimes blank right at the startup of the app (maybe it takes a moment for the accelerometer to be enabled?).

gabibalaban
Level: Powered On

Re: Detect web browser users

An exceptional idea !!!

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Top Community Contributors for September  2019

Top Community Contributors for September 2019 🎉🎉

Let's thank our top community contributors

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 418 members 5,740 guests
Please welcome our newest community members: