CRM Crate

In this blogpost, we will learn to get information about the current host running your Canvas App using Power FX formula. Before we begin, ensure you’ve subscribed to CRM Crate to stay informed about the latest in the Power Platform field.

Get Information about the current Host running your Canvas App

Power FX formulas in Canvas Apps are essentially the building blocks of functionality. They’re like little bits of instructions that you write to make your app do specific things. For instance, imagine you have a slider in your app that lets users select a value. You might want to show different messages depending on what value they choose. In that case, you’d write a Power FX formula that says something like: “If the slider value is greater than 50, show this message, otherwise show a different one.”

These formulas let you add all sorts of logic and actions to your app without having to write tons of code from scratch. Whether it’s performing calculations, fetching data from a database, or controlling how elements behave, Power FX formulas make it easier for you to bring your app to life.

How to get Information about the current Host running your Canvas App?

You can retrieve the information about the current host running your Canvas App using “Host” object in Power App. The Host object provides details regarding the device hosting the application, including its operating system and the user running the application.

One great way to utilize the “Host” object is for troubleshooting an app that’s experiencing issues on a particular device or browser. Utilize the text properties within this object to showcase information in the app’s user interface using a Text label control.

Get user agent information used by the browser:

The text property BrowserUserAgent holds the entire user agent string that the browser employs to recognize itself while running the Canvas App. As an example, consider a browser’s user agent string, which could be:

  1. Chrome/ Safari/537.36 Edg/109.0.1518.78
  2. AppleWebKit/537.36 (KHTML, like Gecko)
  3. Mozilla/5.0 (Windows NT 10.0; Win64; x64)

It is important to note that if you’re running Power Apps in a native app or using the the wrap feature in Power Apps, the app is presented via a browser control, which supplies a user agent string.

Set(variable, Host.BrowserUserAgent)

Get operating system name:

The OSType property provides you the name of the operating system where the Canvas App is operating. This information is derived from the user agent string transmitted by the browser to Power Apps. Here are some typical values for OSType:

  1. Android
  2. Windows
  3. macOS
  4. iOS
  5. Linux
Set(variable, Host.OSType)

Get application’s Session ID:

If you encounter an issue with an app in Power Apps, providing a session ID can significantly enhance Microsoft’s ability to troubleshoot the problem.. The SessionID property retrieves a GUID that uniquely identifies the ongoing session. Remember to include this information when reporting any issues to your administrator.

Set(variable, Host.SessionID)

Get user’s Tenant ID:

The TenantID property offers a Globally Unique Identifier (GUID) that identifies the Microsoft Entra / Azure AAD tenant linked to the currently authenticated user or logged in user.

Set(variable, Host.TenantID)

Get application’s player version:

The Version property gives you the Power Apps player’s identification and version number. Like BrowserUserAgent, it might return more than one version number, separated by spaces. It is important to note that the Version property is always an empty string when working in Power Apps Studio.

Set(variable, Host.Version)

The below animation demonstrates the retrieval of host information in Canvas App.

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
error: CRM Crate Security Engine - Disabled Right Click & Selection!


Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.