Dear flow experts,
Can you please help me to amend the below json code so that a button in a SharePoint List that runs a certain flow shows only when the value of a column called (Approval Triggered) is set to (New) or (Resubmit):
{
"elmType": "button",
"txtContent": "Get Approved",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"92a6ce98-6eea-4655-878d-312fd096f957\"}"
},
"style": {
"background-color": "grey",
"color": "white",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$_ApprovalTriggered]",
"New"
]
},
"visible",
"hidden"
]
}
}
}
Also, can I have the code to add to Flow Trigger Conditions under trigger settings so that the flow does not run?
Thank you,
works great! Thanks for the assist.
@KurtEichler3000 to do this you'll need to have another column in your SharePoint list which gets updated when the button is pressed and the flow runs. The JSON then has an if statement on the actionParams line to look at the value in that new column:
So in the image above I have column called Control. After the button is pressed the flow changes that column to Published. The JSON changes the button background color and changes the action so that no flow is run and nothing happens when the button is pressed. The JSON for that is as follows:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "Publish",
"customRowAction": {
"action": "executeFlow",
"actionParams": "='{\"id\": \"' + if([$Control] =='','d4e4bb15-504f-44d5-b94c-745ddc4ce1bb','')+ '\"}'"
},
"style": {
"background-color": "=if(([$Control] == 'Published'),'#333333','#1f5f61')",
"color": "white"
}
}
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.
I'm looking to do something similar. Instead of making the value hidden, I want to make the value just text or unactionable to prevent the PA from being launched. visibility doesn't work in my case since I want to value to be visible. Below is my JSON. I also tried:
"action": "=if([$TestLead] != '',executeFlow,'')",
and
"action": "=if([$TestLead] != '','executeFlow','')",
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"IRemovedThisID\"}"
},
"attributes": {
"class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
},
"style": {
"border": "none",
"background-color": "transparent",
"cursor": "pointer",
},
"children": [
{
"elmType": "span",
"attributes": {
},
"style": {
"padding-right": "6px"
}
},
{
"elmType": "span",
"txtContent": "=if(([$TestLead]!='','Start Appoval','Missing Test Lead')"
}
]
}
@RobElliott It perfectly works now after I removed the space and changed the != to ==. Thanks a lot.
Can you also help with the same exact conditions but to be added to "Trigger Conditions" of the flow instead so that the flow will not run even when a user tries to run it manually through Automate option in the list menu.
@WAM2 the most likely error is in the [$Approval Triggered]. you need to use the internal name of the column so try [$ApprovalTriggered] (I never use spaces in column names, it just causes too many issues). You've also kept my not equals to != so change that to ==
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
Thank you for your feedback. Yes, this is exactly what I want. But I am afraid it is not working form me. My column name is (Approval Triggered) and the two values that I want the button to be visible on are (New) and (Resubmit). I added these as per the below syntax but it is not working. I appreciate you have a look and let me know of any mistake. Thanks
{
"elmType": "button",
"txtContent": "Reclaim Time",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"92a6ce98-6eea-4655-878d-312fd096f957\"}"
},
"style": {
"background-color": "#02767a",
"color": "#ffffff",
"outline": "transparent",
"border-width": "1px",
"border-style": "solid",
"border-color": "transparent",
"cursor": "pointer",
"font-size": "12px",
"visibility": "=if(([$Approval Triggered] == 'Resubmit') || ([$Approval Triggered] != 'New'),'visible','hidden')"
}
}
@WAM2 the following JSON is hopefully what you need. but you'll need to change the txtContent, the 2 columns and the ID of the flow to your flow's ID:
{
"elmType": "button",
"txtContent": "Reclaim Time",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"355cfb96-ddc5-4911-956c-9705f7557ee5\"}"
},
"style": {
"background-color": "#02767a",
"color": "#ffffff",
"outline": "transparent",
"border-width": "1px",
"border-style": "solid",
"border-color": "transparent",
"cursor": "pointer",
"font-size": "12px",
"visibility": "=if(([$FlowHasRun] == 'No') || ([$Status2] != 'Completed'),'visible','hidden')"
}
}
|| is for Or and && is for And.
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.
Thanks @SteveYao!
I reviewed the documentation but I still unable to figure out how to add another condition to the JSON code provided as I am not a programmer and need basic help. Regards
Hi @WAM2
Have you referred to this documentation?
https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting
David_MA
276
Super User 2025 Season 1
Michael E. Gernaey
245
Super User 2025 Season 1
stampcoin
212