cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NigelP
Super User
Super User

SharePoint For A Selected Item only works if PowerAutomate Flow is in the Default Environment

Hi

 

Am I correct in assuming that SharePoint "For A Selected Item" only works if the PowerAutomate Flow is in the Default Environment ?

 

Is there a way to trigger on when a List Item (Or Document in a Document Library) is selected into a PowerAutomate Flow which is not in a Default Environment ?

 

I have tried both the List Name and the List GUID in For a Selected Item trigger.

 

As a company we discourage the use of the Default Environment other than as a "PlayPen".  Definitely not to be used in a Production Environment.  All PowerAutomate Flows and PowerApps in Production must be in their own environment with appropriate DLPs applied.

 

Regards

 

Nigel

17 REPLIES 17
yashkamdar
Solution Sage
Solution Sage

Hello Team,

 

Am I correct in assuming that SharePoint "For A Selected Item" only works if the PowerAutomate Flow is in the Default Environment ?

 

Yes you are correct,  you cannot trigger Flows that have MANUAL trigger or that need to be triggered on Selected items via any environment other than the DEFAULT environment.

 

 

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

 

 

CFernandes
Super User
Super User

Hey @NigelP 

 

I gave it a try and it did not work for me. I also see that other customer are facing similar problems, https://powerusers.microsoft.com/t5/Building-Flows/quot-For-a-selected-item-quot-Flow-only-works-in-...

 

I can think of a Work around you can create a Flow Launch button using column formatting, https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#create-a... 

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Hi @yashkamdar 

 

So this means I will have to have one PowerAutomate Flow for each Document library and List in my SharePoint Online Estate - currently at around 1628 Document Libraries and Lists which have SP2010 Approval workflows on them according to the PnP Migration Tool !

 

Thats going mean navigating the Default Environment interesting !

 

Regards

 

Nigel

Ho @CFernandes 

 

This solves the problem of the flows not working :- Flow For-Selected-Item trigger and SharePoint Site Pages, in a detective story — John Liu .NET (john...

 

REgards

 

Nigel

Hello Team,

 

Unfortunately there is no easy way out of this. To be honest there are complicated ways and I do not want to mention them because everything comes with a limit anyways.

 

I would have asked you to Clone your Flows meaning Make a copy of your Flow but even that has a limit of 500 right now.

 

I would recommend you to discuss this with Support and check if they have something in place for this scenario, this looks pretty specific.

 

https://flow.microsoft.com/en-us/support/

 

powercorner
Responsive Resident
Responsive Resident

Hello @yashkamdar , @CFernandes @NigelP ,

Is the information above up to date?
We cannot use "Selected Item Trigger" outside of default environment?

Honestly, we are talking about ALM and create environments, take care about the governance and now this? Kind of a neckbreaker!?

 

With regards
Kevin

marcodeluca
Frequent Visitor

Hi @powercorner,

 

I totally agree with you. We are currently introducing Power Platform to our Company. We defined an environment strategy, governance documentation and an ALM process. Now we are facing the same Problem. SharePoint is our main DMS and we have a lot document based workflows, that are business critical. So we need to trigger many Flows starting from Documents or List-Entries. 

ALM does not work in that case because of the known limitations (SharePoint and also Teams triggers - For a selected item/file/message - do not work in other environments).

 

As a Workaround for the really critical Flows we started to create "Dummy Starter" Flows. They run in the "Default environment" (which, by the way, we have renamed to 'Personal Productvity' according to MS recommendation) and trigger the main Flows (ALM aware) via HTTP REST. But this means, that you need Premium Licenses to call the main Flow.

 😞

 

Best Regards

Marco

@NigelP 
Did you find any acceptable solution?

 

I read over the article by John Liu. It suggested using the List GUID ID for the "For A Selected Item" when trying to get a Flow to show up in a SharePoint Site Pages Library, but I still think it was using the Default Environment. I did try using the List ID when I saved a Flow from a different Environment, but the Flow did not show up in the Context Menu.

 

 @NigelP  - Were you able to get a Flow published in an Environment other than the Default Environment to show up in the Context Menu?

 

One of the benefits of creating a Flow with the SharePoint "For A Selected Item" trigger is that it adds the flow to the Context Menu and it is Security trimmed.

 

Others ( @CFernandes ) have suggested creating a button using Column JSON formatting which does work but it lacks the ability to put any Security trimming in place. If the button is clicked by a user without permission to run the flow, the flow dialog just never shows up.

 

 @marcodeluca 
I am interested in more information on the workaround you suggested for using a "Dummy Starter" Flow. How did you identify the correct Environment to run the main flows in (assuming that you have created a Solution that is promoted via ALM to your other Environments of Dev, Staging, and Prod)? How many Premium licenses did you find that this set-up needed?

 

I have also looked at other solutions such as using SPFX to create a ListView command. This implementation would need to launch the flow via an HTTP REST call resulting in the use of Premium Licenses.

It seems the best solution for this issue would be for the Microsoft SharePoint team to add the ability for a Site Admin to select the Power Platform Environment in a setting that the Context Menu would use in it's query to build out the list of Flows for a list.

 

 @yashkamdar 
I have to disagree with you regarding "this looks pretty specific". I guess this goes back to how the Power Platform should be viewed. It is a full fledged development environment where a company would want to have a traditional dev, staging, and production environment. Or should it be viewed more as a citizen developer platform where no one ventures out of a default environment. I think this is an important product enhancement that is best supported by the developer who coded the Context Menu in SharePoint who never realized that there would be an Environment other than the Default one.

 

Best Regards

Mark

@MarkBandR 

We discarded the idea of using the dummy flows, because of the premium licenses. Since I am not a licensing expert I do not recommend you to rely on the info I provide you in this post, but for us according to our TAM: every potential run-only user needed a premium license. Too much for us. So we decided to start the flows via "Flow-Button" using JSON-formatting of a column. For us this means, that we need to manage the start Workflow buttons ourselves.

Exactly, we have DEV, TEST and PROD environments. The correct flow is identified using the Flow Identifier. At the moment we are working on deploying the flow button column (including the JSON formatting) via PnP Provisioning engine as part of our CI/CD pipeline (wich unfortunately is still under construction).

@marcodeluca  Thanks for the reply.

I looked more at using a Flow-Button using the JSON column formatting but I wanted the button to only show up if the user had Permission greater than Read. [$PermMask] is available for this.

 

@MichaelBoehnke documented this here:

https://techcommunity.microsoft.com/t5/sharepoint/column-formatting-show-or-hide-columns-based-on-us...

 

(Thanks @MichaelBoehnke )

 

These are some of the values for [$PermMask] based on the users Permissions:

Full Control     0x7fffffffffffffff

Design             0x1b03c5f1bff

Edit                  0x1b03c431aef

Contribute      0x1b03c4312ef

Read                0xb008431061

View Only        0xb008431041

 

This even works at the item level.

 

Below is an example of Column formatting to show a Flow-Button if the user has Permission greater than Read to the Item:

{

  "$schema": https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json,

  "elmType": "button",

  "customRowAction": {

    "action": "executeFlow",

    "actionParams": "{\"id\": \"YOUR_FLOW_ID\"}"

  },

  "attributes": {

    "class": "ms-fontColor-themePrimary ms-bgColor-themeDark--hover ms-fontColor-themeLighter--hover .ms-ContextualMenubutton"

  },

  "style": {

    "cursor": "pointer",

    "display": "=if([$PermMask]>='0xb00', 'none', '')"

  },

  "children": [

    {

      "elmType": "span",

      "attributes": {

        "iconName": "MicrosoftFlowLogo",

        "class": "ms-font-xxl"

      },

      "style": {

        "padding-right": "6px"

      }

    },

    {

      "elmType": "span",

      "txtContent": "Start Flow"

    }

  ]

}

 

robcaretta
Advocate I
Advocate I

@MarkBandR- Interesting solution. Couple of questions about this:
- Which flow trigger did you use to make this work? Was it "For a selected item"?

- Were you able to make this work in an environment other than Default (Personal Productivity)?

 

@robcaretta For the Flow trigger, I am using the "For a selected item". It gives the Flow the ID of the item. I also used this trigger so I could prompt the user for some additional information.

 

I am not currently using [$PermMask] in the Column Formatting JSON but that is because it has not been a requirement yet.

 

For different environments, you have to get the "Flow identifier" from the "Details" screen of the Flow using "Export"-"Get flow identifier". This value will look something like "v1/YOUR ENVIRONMENT GUID/YOUR FLOW GUID". That value would go in this line of the JSON:

"actionParams": "{\"id\": \"YOUR_FLOW_ID\"}"

 

You can find more information here from MS on the Flow button. You can set other things like headerText and runFlowButtonText

https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/formatting-advanced 

https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/formatting-syntax-referen... (look for "executeFlow")

 

There is another option for launching a Flow that I have not used but thought of using. But using the "setValue" action in the JSON Column formatting you could change a field value and use the "When an item is create or modified" for your trigger. The "customRowAction" would look something like this:

"customRowAction":{

   "action": "setValue",

   "actionInput": {

        "FieldInternalName_1": "FieldValue_1",

   }

}

 

Ref: https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/formatting-syntax-referen... (see setValue)

 

You would set your Trigger - "Settings" - "Trigger Conditions" to look for the field you updated to be a certain value. When the Flow starts, you could immediately change your field back to a reset value. You know who launched the flow by referencing the "Modified By" field when the flow started. 

One advantage to this method is that the user is not prompted with authorizing connections, but you lose the ability to ask for additional information/inputs. You could also use "style" "display" in the JSON to hide the button when the Flow runs by basing the "display" formula on the field value (or multiple field values) that the button click changed/set.

When looking at the options for launching and running a Flow, it is important to also consider the licensing and throttling. Starting flows with "For a selected item" will run under the user that is selecting the item. "When an item is created or modified" will run under the license of the Owner of the flow. If the number of flows you are starting is less that a hundred or so a day, then you should be fine. If it is in the 1000s then you may need "For a selected item". I don't fully understand the licensing and throttling just yet but it is something to be aware of.

 

AlexEncodian
Frequent Visitor

Hi All,

Apologies for jumping into an old thread but hopefully it adds some value. Trigr can deploy a single flow anywhere you need it in SharePoint (without copying it). And you'd be able to trigger said flow even if its not in the Default Environment for selected list items / library files and folders etc.

@NigelP - as Trigr allows you to deploy the Flow across SharePoint (or any group of lists / libraries you choose), you would not need to copy the flow for each targeted library. No more duplication and maintenance of flows!

@MarkBandR - the next release in early November will security trim flows deployed by Trigr based on the AD group permissions of the user in SharePoint. So flows deployed by Trigr will be security trimmed.

It comes with some other cool functions like the ability for multi list item / multi document selection to trigger flows on as well as user dynamic form input etc

Hope this helps for some ALM / other use cases!

cc @powercorner / @marcodeluca / @robcaretta / @CFernandes / @yashkamdar 



robcaretta
Advocate I
Advocate I

@MarkBandR-  Strange I am not able to get this working. I have a very basic flow is using the "For a selected item". Using the MS code with the proper flow ID. The flow is in a another environment though. It just does not trigger. Are you certain this technique works in non-default environments?

@robcaretta It does work. You need to check you "Run only users" from the Details screen for the flow to make sure you have set access. If the Flow is within a Power Automate Solution, you will need to set it to a group from that Environment (try typing "org" to find the group that contains everyone in that Power Automate Environment". If you are not in a Power Automate Solution, then you can select the SharePoint List for who can run it.

 

You also need to look at the Environment in Power Automate Admin to make sure the user has a "Basic User" Permission. In other words they are licensed in that Environment.

 

If they are clicking on the button and nothing is happening, then it is Permissions at some level either to the Flow or to the Environment.

marcodeluca
Frequent Visitor

@robcaretta make sure, that you get the flow ID from here:

marcodeluca_0-1666621099506.png 

Otherwise, the flow will not start because the reference to the environment is missing.

 

Regards
Marco

robcaretta
Advocate I
Advocate I

Microsoft documentation here for "executeFlow" represents it as just the GUID for the flow.  So that is not entirely accurate.

 

Got it.  So it's the FULL identifier like this v1/{EnvironmentGUID}/{FlowGUID}, not just a portion of it. I was able to get it to fire off now.  Thank you for the prompt responses!!!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,749)