Background
Power Automate is a great tool to automate SharePoint based Tasks, e.g. Document Approvals, Notifications,... The flows can be triggered by a new or changed Element / Document in SharePoint, but very often, we want the user to start a flow for a specific, selected document. For that, Microsoft is Providing a Power Automate Trigger called "SharePoint - Start for the selected document", which can be triggered for the selected document in SharePoint. The flow gets the ID of the selected document and can do anything you want with that document. In this post, I explain, how to trigger a flow, that is located in another environment than the default environment
How does the integration work
This is great - BUT - in the past the flow needs to sit in the default Power Platform Environment, that SharePoint can trigger it. The reason for that is easy explained - let's have a look on the integration in the SP List.
To start the flow from the SP List, we add a text field to the list, add a custom formatter to that field and reference there to the ID of the Flow
The JSON for the custom formatter looks like that:
{
"$schema": "https: //developer.microsoft.com/en-us/json-schemas/sp/column-formatting.schema.json",
"elmType": "span",
"style": {
"border": "none",
"background-color": "#0029b0",
"color": "#0078d7",
"cursor": "pointer",
"width": "100px",
"margin": "5px",
"border-radius": "20px",
"visibility": "visible"
},
"children": [{
"elmType": "button",
"txtContent": "Start my FLow",
"style": {
"border": "none",
"background-color": "transparent",
"color": "white",
"cursor": "pointer"
},
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"0000000-0000-0000-0000-0000000000\"}"
}
}]
}
The relevant part is
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"0000000-0000-0000-0000-0000000000\"}"
}
The Problem
You see that the action "executeflow" only takes a Parameter "id" which is the flow id. If the flow is not located in the default environment, the button will not work. From a good Power Platform Governance not a very nice approach, as Microsoft is telling us to place "real world/mission critical" Flows in other Environments than the Default Env.
But since a few weeks, there is new way to reference to the flow which has the Environment ID included.
To find that link, let's switch to the Power Automate Maker Workbench at https://flow.microsoft.com
First lets validate we are not in the Power Platform default environment
Next I create a very simple flow with the SP-trigger "for the selected item"
After saving and exiting from the flow workbench, we can get the identifier of the flow, via the "Export" Menu
The identifier looks like that
v1/00000000-0000-0000-0000-000000000000/00000000-0000-0000-0000-000000000000
And here is the magic - the ID consist of the the Environment ID + the Flow ID. We can us that in the custom formatter in the SharePoint List
And we can the start the flow from the SP List
Why is this so important?
In a good Power Platform Governance, we (and also Microsoft) is recommending to use the "Default Environment" as a "Personal or Playground" Environment, not as a Productive Place. But as long as we could not reference to other then the Default Environment from a SharePoint List to start a Flow, we had to use the Default Environment for that. With that trick, now it is possible to have a "clean" Default environment (maybe using the Power Platform CoE Starter Kit).
If you want to learn more about a good Power Platform Governance, contact us!