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.
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:
- Chrome/18.104.22.168 Safari/537.36 Edg/109.0.1518.78
- AppleWebKit/537.36 (KHTML, like Gecko)
- 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.
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:
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.
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.
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.
The below animation demonstrates the retrieval of host information in Canvas App.