Sep 20 2021 02:52 AM
Hello Everyone,
I would like to create a button in SharePoint that, when pressed, enters the following in two other columns, by whom the button was pressed and when this button was pressed. My question is now how I can best implement this or if someone can already show a solution for this.
I thank you
Sep 20 2021 04:19 AM - edited Sep 20 2021 04:21 AM
@Tison5 you can do this with a simple flow in Power Automate and a JSON-formatted button.
First, create your columns in the list. In my example I have:
Button | Single line of text |
Pressed | Yes/No |
PressedBy | Person |
PressedOn | Date/Time including the time |
Next create an instant cloud flow in Power Automate use the SharePoint "for a selected item" trigger.
The first item needs to be the SharePoint "get item" and you select ID from the dynamic box that appears when you click in the Id field.
Finally, add a SharePoint "update item" action. Select ID and Title (if it's a required column) then for the Pressed column select Yes from the dropdown. For the PressedBy column select Modified By Claims. For the PressedOn column click in the field and when the dynamic content box appears chosse the Expression tab and enter the expression utcNow() and press OK.
In the top left of your flow change the name to something relevant. Click Save in the top right of the flow. Then click the left arrow in the top left of the flow to go to the flow's main screen.
Next copy the ID of the flow:
Next, format your Button column:
and go to the Advanced mode screen:
Copy & paste the following JSON code, changing the text you want in the button (the txtContent line) and making sure that in the actionParams line you change the flow ID to yours. You can also style the button with css:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "Press this button",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"70bcc1be-c1af-436c-94a6-50828b1582ef\"}"
},
"style": {
"background-color": "#460302",
"color": "#ffffff"
}
}
Save it. When you click the button the flow will trigger and put in the data into the columns:
Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)