SOLVED

Create a button in sharepoint Online

Copper Contributor

Hi,

I need  to add a button (as seperate column)  in my Sharepoint Online list which will be visible when another column "Approval Status" has 'Pending' value and then when I click this button will change the status of Approval Status from Pending to Approved.

.Approval Status is choice column.

Can you please advise.

 

Thank you

6 Replies
You need to use Flow to accomplish this, and luckily Laura Rogers has a video which demonstrates I think exactly what you want to accomplish. Check this video out.
https://www.youtube.com/watch?v=C-oLlVtRrUk

Thank you Chris, Although this link is referred about the MS flows , while I need just to change the status of a specific field by clicking a button.

 

I tried also to follow the video(Laura) with trigger MS flow but it doesn't work, please see below the json code.

ere is the json :

 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
“elmType”: “button”,
“txtContent”: “Get Approved”,
“customRowAction”: {
“action”: “executeFlow”,
“actionParams”: “{\”id\”: \”4f74601c-6756-43b1-bfed-914a1fc5b321\”}”
},
“style”: {
“background-color”: “purple“,
“color”: “white”
}}

 

Can you please advise..

 

Thank you

 

 

best response confirmed by edok1280 (Copper Contributor)
Solution
I'm fairly certain you can't just click a button to update a field in modern UI right in line in the list, hence why people put buttons for flows to do some action. You need to create your own flow with the logic you want to happen when clicking that button. Once that's done and working by using the Flow Drop down menu for "Selected Item" then you can use the Column Formatter to add a shortcut / Button to that flow and use the ID from the flow etc.

Thank you Chris.

 

I have already done that , but unfortunately it doesn't work.. It works OK by using the Flow Drop down menu for "Selected Item" .

 

Can you please check the Json formatting, it says that there is error...

 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
“elmType”: “button”,
“txtContent”: “Get Approved”,
“customRowAction”: {
“action”: “executeFlow”,
“actionParams”: “{\”id\”: \”4f74601c-6756-43b1-bfed-914a1fc5b321\”}”
},
“style”: {
“background-color”: “purple“,
“color”: “white”
}}

 

Thank you

 

Check this documentation out, linked to the flow section. That might be an old way or something. Hopefully this can help out:
https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#create-a...
I followed Laura's documentation but the copy/paste of JSON code wasn't recognised.
Laura made a comment down the bottom that this sometimes happens, and to type the code out yourself. I did a find/replace on all the special charactors, and this fixed it. My code:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "Publish",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"50022e3e-c14c-4c5c-8057-f215148f6b3f\"}"
},
"style": {
"background-color": "purple",
"color": "white",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Status]",
"Requires Review"
]
},
"visible",
"hidden"
]
}
}
}

I know it's 3 years too late, but this might still help you, and others :)
1 best response

Accepted Solutions
best response confirmed by edok1280 (Copper Contributor)
Solution
I'm fairly certain you can't just click a button to update a field in modern UI right in line in the list, hence why people put buttons for flows to do some action. You need to create your own flow with the logic you want to happen when clicking that button. Once that's done and working by using the Flow Drop down menu for "Selected Item" then you can use the Column Formatter to add a shortcut / Button to that flow and use the ID from the flow etc.

View solution in original post