cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SamPo
Power Participant
Power Participant

SharePoint - For a selected file Trigger

Hi All,

 

I'm trying to use the SharePoint trigger "For a selected file". I don't understand how to make this flow run. I've opened a number of files from the selected SharePoint document library from the same user that created the flow but nothing runs.

 

I found this thread: https://powerusers.microsoft.com/t5/General-Power-Automate/Sharepoint-trigger-for-a-selected-item/td...

 

It is very unclear there if this trigger is supposed to work at all and how it's actually meant to work.

Can someone who understands this please advise?

 

Thanks

Sam

1 ACCEPTED SOLUTION

Accepted Solutions
ChristianAbata
Community Champion
Community Champion

hi @SamPo  for a selected file means that you need to clic on the file to see the flows that you have created.

see

 

file.png

 

when you create a flow for a selected file you are going to be able to see your created flow in the list of automate, clicking right on your file.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

View solution in original post

12 REPLIES 12
ChristianAbata
Community Champion
Community Champion

hi @SamPo  for a selected file means that you need to clic on the file to see the flows that you have created.

see

 

file.png

 

when you create a flow for a selected file you are going to be able to see your created flow in the list of automate, clicking right on your file.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
RobElliott
Super User
Super User

@SamPo  the "For a selected file" does indeed work and works very well. One way I use it several times a week is to publish an adaptive card to our company's All-Staff Teams site whenever I publish a news item on our SharePoint intranet (just another method of putting news in front of staff!)

I have a column in my Site Pages library on our intranet that is a single line of text column, formatted with JSON to show a button that is linked to the flow. When you click on the button the flow starts and posts the item to the Teams channel. The actionParams line should have the  ID of your flow, so you'll need to create the flow first:

0-SP-list.png

The JSON code is as follows (don't forget to change the ID of the flow to yours and to change or delete the  the visibility line:

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Publish to Teams",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"021ec4e0-8f85-46b3-a557-a4456960a4eb\"}"
  },
  "style": {
    "background-color": "#468259",
    "color": "white",
    "visibility": "=if(([$PublishedToTeams] == 'Yes'),'hidden','visible')"
  }
}

 

The flow looks like this with the trigger being a SharePoint "For a selected file":

1-flowTrigger-Compose-Get-Compose.png

 

2-Apply-Compose-Post.png

I then update the Site Pages library and switch the PublishedToTeams column to Yes which hides the button in the list. 

3-Update.png

 The result in Teams looks like this:
4-resultTeams.png

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

SamPo
Power Participant
Power Participant

@RobElliott @ChristianAbata Thanks both for the detailed explanations.

@SamPo  you are welcome, please consider to mark an aswer as solution to guide others



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

Hi @RobElliott 

 

Not sure if my previous msg was posted. 

 

Does the button works only for flow owners? I created a button "Start flow" similar to yours "Publish to Teams" and it triggers the flow, but only for me(flow owner) and not for other users.

 

Is there any solution for this? I need the flow to be triggered for all sharepoint site users and not only for me.

Yes I have the same issue/question. Is there any way to allow other user to trigger the flow?

benny_blanco
Helper I
Helper I

Is that trigger For Selected File only a manual process, I mean, it works only if you go to the file and click on the flow, can't it be set to run automatically only whenever this particular file is modified? Let's say you have 11 more other documents in the same library, can you trigger a flow to run specifically for the selected document only, not for the other ones?

@benny_blanco the For a Selected File trigger is a manual trigger for a specific file, usually in my case from a button in a SharePoint list/library. What  you need to use is When a file is created or modified. That will only run for the specific file that has been modified.

 

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

benny_blanco
Helper I
Helper I

@RobElliott I know which is the trigger to be used for when an item is modified. Looking for something that will automatically trigger only for a selected document. Let's say we have 11 files in the same document library, each having a separate Flow set to trigger itself on item modification. But I want each Flow to only run for its own document, otherwise each Flow runs for all modified documents. Let's say out of the 11 documents only 2 are modified, but all 11 automations will run as well. In this case I'm looking how to make out of the 11 flows only the two that are related with the modified documents to run for them, the other 9 to check if the modification is for their related documents and if not, to stop and not run. Any ideas how to achieve that? Thank you!

@benny_blanco The For a selected file trigger requires you to select the item for which you want the flow to run, it won't run automatically. Then, as I mentioned in my previous post, you can have a JSON-formatted button in a single line of text column in your list or library. Selecting the button against each item will run the flow.

 

postButton.png

 

The JSON for that example is below:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Publish to Teams & Yammer",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"021ec4e0-8f85-46b3-a557-a4456960a4eb\",\"headerText\":\"All Things REI\",\"runFlowButtonText\":\"Publish Now\"}"
  },
  "style": {
    "background-color": "#468259",
    "color": "white",
    "visibility": "=if(([$PublishedToTeams] == 'Yes'),'hidden','visible')"
  }
}


If I've misunderstood then you'll need to post some screenshots of what your flows are trying to do.

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

 

Hi @RobElliott ,

I'm getting back on a question posted by @Anand.

Does the button works only for flow owners?

.......

I need the flow to be triggered for all sharepoint site users and not only for me. In addition to @Anand I also need to button for everybody has the link to the public sharpoint document folder. I mean, users without authentication.
Thanks

Hi @RobElliott , 

 

I have a similar requirement of running the workflow 'For a Selected File' trigger with the click of a button.

 

The overall idea is to develop a User Interface(UI) where the user can select a SharePoint site from the drop down list which will then pop up another drop down list displaying all documents from the site's document's library. The user will then select a document and click on 'Run' to run the workflow from the UI. So I was wondering that since we know the site URL and document ID at this point, if it is possible to run the workflow automatically i.e. Instead of users going to the SharePoint site and selecting 'Automate -> Approval workflow' from the ellipsis menu? Please let me know how can I accomplish this. 

 

PS: We created power automate flows using the Power automate Web API and each SharePoint site has its own approval workflow ( i.e. each site has a different workflow id)

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,230)