Skip to content

Updating the Total Shared column for canvas apps on demand in CoE Starter Kit

Power Platform Center of Excellence Starter Kit provides a broad set of tools for administrators to analyze how apps and automations are being built and used within their Microsoft 365 tenant. With the latest updates, the Power BI dashboard in CoE Starter Kit is now easier to use for filtering and drilling down to the many metrics that the inventory database collects about Power Apps, Power Automate and other elements of the low-code platform.

Unlike Microsoft’s built-in reports in the Power Platform Admin Center (PPAC), the source of data for CoE Starter Kit tools and reports is a Dataverse environment that the customer themselves needs to manage. The benefit from this approach is the ability to create custom reports, as well as extend the data model with custom columns for specific governance requirements of the organization. On the other hand, if there is something missing or wrong with the metrics, it is up to the Power Platform administrator / governance team to investigate what’s causing this. Today we’ll look at once example of such a scenario.

Have you ever wondered why you’re not seeing the “Total Shared” column in CoE’s Power Platform Admin View app reflect the actual number of users a canvas app has been shared with? Especially with a fresh CoE installation, the column in the app can be empty and the “Total Shared With” column of the “App Deep Dive” page in the Power BI can be full of zeros. In this post we’ll look at the reasons behind the zeros and a way of getting the latest up-to-date values on demand.

Image 1. Total Shared displaying zero for canvas apps despite known app shares.

Background – How the Total Shared column works

First off, it’s worth pointing out that of the 2 different types of Power Apps, only canvas apps are shared. Model-driven app access is based on security roles. On the Power Automate side, shared cloud flows (when a user is added as a co-owner or run-only user) are not surfaced in CoE, albeit co-owners and run-only users can be listed with the “Get Flow Owner Role as Admin” and the “List Flow Owners” actions.

The App shared with list

CoE lists all users with whom a canvas app is shared with. This information is available in the Power Platform User Role (admin_powerplatformuserroles) table in your CoE Starter Kit environment’s Dataverse database. Users an app has been shared with can be seen in the CoE’s Power Platform Admin View app, when looking at a canvas app in the PowerApps App (admin_apps) table. In image 2 below we can see that a canvas app is shared with four users.

Image 2. Canvas app from the context of the Power Platform Admin View app.

Now that we understand the way the App shared with list works, we need to understand how it gets updated. There’s (little) voodoo here. The list is updated by a background flow called CLEANUP – Admin | Sync Template v3 (Power Apps User Shared With). The (little) bit of that voodoo exists is that the flow runs on a recurrence of every two weeks. It’s what I call a heavy lifter as it’s a long running flow that crawls through every single app for their sharing state.

As the flow only runs every two weeks, your App shared with list is guaranteed to not tell you the whole truth about an app’s sharing state. The good thing is we can manually run this flow on demand. Personally, I keep the flow in my Edge bookmarks and run it whenever I need to update the App shared with list for canvas apps. It is a long running flow so don’t expect immediate results.

The Total Shared column

Next, let’s look at the Total Shared (admin_totalshared) column seen in image 2. Surprise, surprise, it’s a rollup column! This means that it won’t show the truth behind the App shared with list before:

Since we’ve already established that we can get the App shared with list updated by running the aforementioned flow on demand, it’s now time to consider how we can recalculate the Total Shared rollup column on demand for all our canvas apps in the PowerApps App table.

Forcing recalculation for rollup columns programmatically

The nice thing about could flows is that we can call the Dataverse Web API from a flow. If you want to get to the nitty gritty on how it’s done, be sure to check out this blog post by Elaiza Benitez. The flow you can find below as you read this post uses that approach so kudos to Elaiza. Next, let’s go through the on demand flow for forcing recalculation for rollup columns.

The flow

The flow itself is quite simple: List all PowerApps Apps in CoE that are of type canvas, loop through the list, and call the Dataverse Web API. The choice column value for canvas apps in the PowerApps Apps table is 597910000, and the GET request is:

https://envUrlHere.crmx.dynamics.com/api/data/v9.2/CalculateRollupField(Target=@EntitySetName,FieldName=@FieldName)?@EntitySetName={'@odata.id':'admin_apps(appIdHereFromListRows)'}&@FieldName='admin_totalshared'

I’ve used the HTTP with Azure AD connector’s Invoke an HTTP request action in this flow for simplicity’s sake. The actions is handy as an app registration isn’t required and in my example I really have no ALM or other constraints. For a faster execution, remember to set the loop’s degree of parallelism all the way to 50.

Image 3. The flow to recalculate rollups on demand.
CoE Starter KitFlowgovernancePower Automaterollup column

Leave a Reply

Your email address will not be published. Required fields are marked *