Post

#PowerPlatformTip 127: 'Special User-Informations in PowerApps Studio'

#PowerPlatformTip 127: 'Special User-Informations in PowerApps Studio'

TL;DR: Auto-switch to a test email in Power Apps Studio and the real User().Email in production via IsBlank(Host.Version).

🔄 Update (2026-08-21): Two corrections. (1) The Studio check now uses IsBlank(Host.Version) instead of StartsWith(Host.Version, "PowerApps-Studio") - per the official Microsoft documentation, Host.Version is always an empty string in Power Apps Studio and only returns a value in the web or mobile player. (2) Placement fixed: named-formula syntax (name = expr;) can’t go in App.OnStart - use Set() in App.OnStart (Option A) or define Named Formulas in App.Formulas (Option B).

💡 Challenge

While developing apps in Power Apps Studio, you often want to use test values, like a test email address, without risking that they end up in production.

✅ Solution

Check whether the app is running in Studio mode. If it is, use a test email for development; in production the app automatically switches to the real user’s email address.

🔧 How It’s Done

Detect Studio mode with IsBlank(Host.Version) and switch the email accordingly. Pick one of these placements.

Option A - in App.OnStart (use Set):

Set(fxIsStudioMode, IsBlank(Host.Version));
Set(
    fxUserEmail,
    If(
        fxIsStudioMode,
        "testaccount@company.com",
        User().Email
    )
);

Option B - as Named Formulas in App.Formulas (not OnStart):

fxIsStudioMode = IsBlank(Host.Version);
fxUserEmail =
    If(
        fxIsStudioMode,
        "testaccount@company.com",
        User().Email
    );

🔸 Named formulas live only in App.Formulas, are always evaluated automatically and stay up to date - but they can’t be placed in App.OnStart.

🔸 Inside App.OnStart use Set() for a global variable (or UpdateContext() for a screen-scoped one).

🔸 Either way you get the test email during development and the correct user email in production, with no manual changes.

🎉 Result

No more accidentally shipping apps with hardcoded test emails, the switch is seamless and automatic.

🌟 Key Advantages

🔸 Prevents accidental deployment of test data

🔸 Saves time by automating email assignment

🔸 Enhances app security and consistency

Special thanks to Matthew Devaney for sharing this fantastic Power Apps tip!

🎥 Video Tutorial

🛠️ FAQ

1. How do I determine if my app is in Studio Mode? Check whether Host.Version is empty with IsBlank(Host.Version). It returns true in Power Apps Studio and false in the web or mobile player. (Avoid StartsWith(Host.Version, "PowerApps-Studio"), because Host.Version is blank in Studio.)

2. Can I apply this pattern to other test values? Yes, use the same logic to switch between development and production values for any parameter.

3. Where should I place these formulas in my app? Use Set() in App.OnStart (Option A) for a global variable, or define them as Named Formulas in App.Formulas (Option B). Named-formula syntax (name = expr;) can’t be placed in App.OnStart; for a screen-scoped value use UpdateContext().

This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.