SOLVED

Conditional formatting - Button flow inserted in SharePoint list - how to insert a logic condition

Copper Contributor

Hi,

 

I have added a column with  flow button, in my list, using JSON. I am really a beginner in JSON.

I need to add a condition like:

If Status=Pending or Status=Approved with comments, then show "Send to Approval" button.

 

The code is in the attachment.

Any help is highly appreciated.

Thank you!

3 Replies
best response confirmed by Claudia_Polders (Copper Contributor)
Solution

@Claudia_Polders 

the correct code is attached

 

"visibility""if(@currentField == 'Pending', 'visible', if(@currentField == 'Approved', 'visible', 'hidden'))"

 

Thank u

@Hi @Claudia_Polders  the JSON you've provided won't actually trigger a flow as you need to tell it which flow to trigger in the actionparams line.

 

But what you can do is to trigger an approval flow from the button via flow in Power Automate. Do you want me to post the changes to the JSON code and the steps in the flow to do that? If you do I'd recommend you add some columns to your list for the approver decision, approver name, approver date and approver comments. When the apporver has done their bit in the email this approval information can be saved back to your SharePoint list as an action in the flow.

 

So let me know if you need the steps to achieve this.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

@FabioO365GoDsorry, slightly off-topic but thanks for the pointer on showing the button only if a  condition is met. I adjusted it slightly to cope with if another column has a value then hide the button, otherwise show it:
buttonVisibility.png

 

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "button",
   "txtContent": "Send for Approval",
   "customRowAction": {
      "action": "executeFlow",
      "actionParams": "{\"id\": \"355cfb96-ddc5-4911-956c-9705f7557ee5\"}"
   },
   "style": {
      "background-color": "#468259",
      "color": "white",
      "visibility": "=if(([$Control] == 'Published'),'hidden','visible')"
   }
}

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

1 best response

Accepted Solutions
best response confirmed by Claudia_Polders (Copper Contributor)
Solution

@Claudia_Polders 

the correct code is attached

 

"visibility""if(@currentField == 'Pending', 'visible', if(@currentField == 'Approved', 'visible', 'hidden'))"

 

Thank u

View solution in original post