Adventures with Power Platform: You Shall Not Pass!

I wanted to discourage makers from creating applications in the default Power Platform environment.

Unfortunately, I can’t prevent them from doing so in an easy to set up way.

Hmm. 🤔

After giving this some further thought đź’ˇ, maybe I can respond to a change in a Dataverse table, that’s where the Canvas Apps are stored?

That works, but what if a Canvas App isn’t part of a solution? It won’t be in Dataverse.

I can fix that! 🛠️ I can flag the environment to force Canvas Apps and Cloud Flows to be added to a solution.

To do this we have to go to the Power Platform Admin Center.

  1. Navigate to https://aka.ms/ppac.
  2. Click on Environments.
  3. Select the default environment from the list, often called Personal Productivity, the type of the environment is set to Default.
  4. Click Settings.
  5. Click Features.
  6. Scroll down to the Create new canvas apps and cloud flows in Dataverse solutions.
  7. Toggle Canvas apps.
  8. Toggle Cloud flows.
  9. Click Save.

Figure 1 – Updating environment features in the Power Platform Admin Center

Now any time a maker creates a Canvas App or Cloud Flow it will automatically be added to a solution. 🎉

Next, I want to send the maker an email ✉️ anytime they create the Canvas App and let them know they need to move their app to an approved Environment.

I can do this with a Cloud Flow.

The Cloud Flow will trigger off of an Add in the Canvas App Dataverse table.

I created a Solution with these Components:

Monitor Administrator EmailEnvironment VariableThe email address for the administrator who will be notified whenever a Canvas App is created.
Monitor Help URLEnvironment VariableThe URL of the site to direct makers to identify the appropriate environment.
Monitor Microsoft Dataverse Connection ReferenceConnection Reference
Monitor Office 365 Outlook Connection ReferenceConnection Reference
Monitor On Canvas App Added (Automated)FlowMonitors changes in the Canvas App Table.

Let’s take a look đź‘€ at the Flow.

I am using a Dataverse trigger for When a row is added, modified or deleted.

  • Change Type is Added
  • Table Name is Canvas Apps
  • Score is Organization

Figure 2 – Dataverse trigger responding to change in table

I next add a Dataverse List Rows action.

Why? Because I need to get the email of the maker who created the Canvas App.

  • Table Name is Users
  • Select Columns is internalemailaddress,firstname,fullname,lastname
  • Filter Rows is azureactivedirectoryobjectid eq @{triggerBody()?['aadcreatedbyid']}
  • Row Count is 1

Figure 3 – Dataverse action to get the maker’s email

Lastly, I add an Outlook Send an email (V2) action.

This action will automatically add an Apply to each action, which is OK. Only one record will ever be returned, so it’s not doing any extra work here.

  • To is "@items('Apply_to_each_-_Users')?['internalemailaddress']
  • Subject is Action Needed: Canvas App Created in Incorrect Environment
  • CC is @parameters('Monitor Administrator Email (sample_MonitorAdministratorEmail)')
  • Importance is High

The Body of the message is as follows:

Figure 4 – Send an email to the maker and the administrator

Let’s test it out.

I add a Canvas App, wait a minute or two, and then check Outlook, and sitting in my inbox is an Action Needed: Canvas App Created in Incorrect Environment message. đź‘Ť

Figure 5 – Message notification

Can I do the same with Flows or other Components?

I imagine you can do similar once the Dataverse tables have been identified.

This might not be the most elegant solution, but it works.

If you have a better way of handling this, please share! Always looking for ways to improve. đź’Ş


Discover more from Matt Ruma

Subscribe to get the latest posts sent to your email.

Leave a Reply

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