Thursday, January 16, 2020

How To Determine If Your Canvas App Is In Studio Or Play Mode

Sometimes, you want to run different logic if you’re editing a canvas app, vs “playing” a canvas app.  There is no out of the box function to call, but there is a fairly small work around for it:

/*********************************
 * Determine Studio or Play mode *
 *********************************/
SaveData([true], "IsMobileApp"); // SaveData only works in the Power Apps App, not the web player
Clear(IsMobileApp);
LoadData(IsMobileApp, "IsMobileApp", true);
// TenantId is required for the web player SaveData only works in the Power Apps App, 
// not the web player so if both are blank/empty then it's studio mode
Set(AppMode, If(IsBlank(Param("tenantId")) && IsEmpty(IsMobileApp), "Studio", "Play"));

 

Since the TenantId is included in the URL for the play web page, and you can’t open the studio from the PowerApps Mobile App, the function should cover all bases for determining if you’re in Studio or Play mode.  This makes it possible to automatically change how the app behaves if it is opened in Studio mode.  I personally use it to show certain hidden sections of the app that are helpful when debugging/creating.

 

Enjoy!

2 comments:

periyannan said...

Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
evs full form
raw agent full form
full form of tbh in instagram
dbs bank full form
https full form
tft full form
pco full form
kra full form in hr
tbh full form in instagram story
epc full form

Amit K P TTR said...

I got such a useful stuff on your website that helps me a lot to gain information.

Government Jobs in Dadra & Nagar Haveli | ba 3rd year result 2021-22 subject wise