Forum Discussion
Sharepoint button to run a Power Automate flow.
SimonMarkEdwards it's not a url you need, it's the ID of the flow. You get this from the main screen of the flow as follows:
If your button is in a document library or the Site Pages library then the trigger in your flow needs to be "For a selected file". If the button is in a list then the trigger should be "For a selected item".
You then need a single line of text column in your list/library and format it with the JSON below. You'll see the ID on the actionsParams line; you'll need to change this to your flow's ID and also change the header text and run flow button text to whatever you want and also change the txtContent line (the text on the button). And of course you change the style to however you want it to look. You'll notice that I've got the visibility as conditional based on another column (set to Yes in the flow):
{
"$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\",\"headerText\":\"All Things REI\",\"runFlowButtonText\":\"Publish Now\"}"
},
"style": {
"background-color": "#008082",
"color": "white",
"border-radius": "0 15px",
"visibility": "=if(([$PublishedToTeams] == 'Yes'),'hidden','visible')"
}
}
The end result of the above formatting looks like this. Click the button and flow will start:
I hope that has prevented you going bald.
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
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.
RobElliott​ What are other visibility rules you can apply?
For example can I show button for a specific file type?
OR show for items but not folders?
I haven't found any documentation on this so if you have a link where I can learn more that would be helpful too.
Thanks for the great post!
- Rob_ElliottDec 09, 2025Silver Contributor
RicardoBDR​ to display only a specific file type you could add the following:
"display": "=if([$File_x0020_Type] == 'png', 'inline-block', 'none')"
To display the button only for files but not folders add the following:
"visibility": "=if([$File_x0020_Type] == '', 'hidden', 'visible')"And you could add both!
A site I've always found very useful for seeing what's possible and grabbing the JSON is at https://pnp.github.io/List-Formatting/
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, Power Platform, WSP Global (and classic 1967 Morris Traveller driver)