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.
- Navigate to https://aka.ms/ppac.
- Click on Environments.
- Select the default environment from the list, often called Personal Productivity, the type of the environment is set to
Default
. - Click Settings.
- Click Features.
- Scroll down to the Create new canvas apps and cloud flows in Dataverse solutions.
- Toggle Canvas apps.
- Toggle Cloud flows.
- Click Save.
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 Email | Environment Variable | The email address for the administrator who will be notified whenever a Canvas App is created. |
Monitor Help URL | Environment Variable | The URL of the site to direct makers to identify the appropriate environment. |
Monitor Microsoft Dataverse Connection Reference | Connection Reference | |
Monitor Office 365 Outlook Connection Reference | Connection Reference | |
Monitor On Canvas App Added (Automated) | Flow | Monitors 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
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
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<p>Hi @{items('Apply_to_each_-_Users')?['firstname']},<br> <br> You have created a Canvas App, called <b>@{triggerOutputs()?['body/displayname']}</b>, in the wrong environment.<br> <ul> <li><b>Display name</b>: @{triggerOutputs()?['body/displayname']}</li> <li><b>Canvas App name</b>: @{triggerOutputs()?['body/name']}</li> <li><b>Canvas App Id</b>: @{triggerOutputs()?['body/canvasappid']}</li> <li><b>App Open Uri</b>: <a href=" @{triggerOutputs()?['body/appopenuri']}">@{triggerOutputs()?['body/appopenuri']}</a></li> </ul> Please review the documentation at <a href="@{parameters('Monitor Help URL (sample_MonitorHelpURL)')}"> @{parameters('Monitor Help URL (sample_MonitorHelpURL)')}</a> to determine which environment you need to be working in as well as instructions for how to move your Canvas App.<br> <br> <span style="color: red;">This Canvas App will be deleted in 30 days.</span> <br> <br> Thanks,<br> <br> Power Platform COE Team</p> |
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. 👍
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.
Just use the admin connectors to get the information (filtered to default environment)
https://www.youtube.com/watch?v=FsZjtLl-3Ac
I’ll have to check that at! Thanks for sharing!