SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-1187239%22%20slang%3D%22en-US%22%3EConditional%20formatting%20-%20Button%20flow%20inserted%20in%20SharePoint%20list%20-%20how%20to%20insert%20a%20logic%20condition%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1187239%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20added%20a%20column%20with%26nbsp%3B%20flow%20button%2C%20in%20my%20list%2C%20using%20JSON.%20I%20am%20really%20a%20beginner%20in%20JSON.%3C%2FP%3E%3CP%3EI%20need%20to%20add%20a%20condition%20like%3A%3C%2FP%3E%3CP%3EIf%20Status%3DPending%20or%20Status%3DApproved%20with%20comments%2C%20then%20show%20%22Send%20to%20Approval%22%20button.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20code%20is%20in%20the%20attachment.%3C%2FP%3E%3CP%3EAny%20help%20is%20highly%20appreciated.%3C%2FP%3E%3CP%3EThank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1187239%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EConditional%20Formatting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFlow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20List%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1187346%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20-%20Button%20flow%20inserted%20in%20SharePoint%20list%20-%20how%20to%20insert%20a%20logic%20condit%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1187346%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F490348%22%20target%3D%22_blank%22%3E%40Claudia_Polders%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Ethe%20correct%20code%20is%20attached%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%22visibility%22%3C%2FSPAN%3E%3CSPAN%3E%3A%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22if(%40currentField%26nbsp%3B%3D%3D%26nbsp%3B'Pending'%2C%26nbsp%3B'visible'%2C%26nbsp%3Bif(%40currentField%26nbsp%3B%3D%3D%26nbsp%3B'Approved'%2C%26nbsp%3B'visible'%2C%26nbsp%3B'hidden'))%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20u%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1187370%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20-%20Button%20flow%20inserted%20in%20SharePoint%20list%20-%20how%20to%20insert%20a%20logic%20condit%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1187370%22%20slang%3D%22en-US%22%3E%3CP%3E%40Hi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F490348%22%20target%3D%22_blank%22%3E%40Claudia_Polders%3C%2FA%3E%26nbsp%3B%20the%20JSON%20you've%20provided%20won't%20actually%20trigger%20a%20flow%20as%20you%20need%20to%20tell%20it%20which%20flow%20to%20trigger%20in%20the%20actionparams%20line.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20what%20you%20can%20do%20is%20to%20trigger%20an%20approval%20flow%20from%20the%20button%20via%20flow%20in%20Power%20Automate.%20Do%20you%20want%20me%20to%20post%20the%20changes%20to%20the%20JSON%20code%20and%20the%20steps%20in%20the%20flow%20to%20do%20that%3F%20If%20you%20do%20I'd%20recommend%20you%20add%20some%20columns%20to%20your%20list%20for%20the%20approver%20decision%2C%20approver%20name%2C%20approver%20date%20and%20approver%20comments.%20When%20the%20apporver%20has%20done%20their%20bit%20in%20the%20email%20this%20approval%20information%20can%20be%20saved%20back%20to%20your%20SharePoint%20list%20as%20an%20action%20in%20the%20flow.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20let%20me%20know%20if%20you%20need%20the%20steps%20to%20achieve%20this.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3EMicrosoft%20Power%20Automate%20Community%20Super%20User%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1187497%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20-%20Button%20flow%20inserted%20in%20SharePoint%20list%20-%20how%20to%20insert%20a%20logic%20condit%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1187497%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F563137%22%20target%3D%22_blank%22%3E%40FabioO365GoD%3C%2FA%3Esorry%2C%20slightly%20off-topic%20but%20thanks%20for%20the%20pointer%20on%20showing%20the%20button%20only%20if%20a%26nbsp%3B%20condition%20is%20met.%20I%20adjusted%20it%20slightly%20to%20cope%20with%20if%20another%20column%20has%20a%20value%20then%20hide%20the%20button%2C%20otherwise%20show%20it%3A%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22buttonVisibility.png%22%20style%3D%22width%3A%20768px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F172534iA6B82DA80FBC5997%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22buttonVisibility.png%22%20alt%3D%22buttonVisibility.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%7B%0A%20%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Fcolumn-formatting.schema.json%22%2C%0A%20%20%20%22elmType%22%3A%20%22button%22%2C%0A%20%20%20%22txtContent%22%3A%20%22Send%20for%20Approval%22%2C%0A%20%20%20%22customRowAction%22%3A%20%7B%0A%20%20%20%20%20%20%22action%22%3A%20%22executeFlow%22%2C%0A%20%20%20%20%20%20%22actionParams%22%3A%20%22%7B%5C%22id%5C%22%3A%20%5C%22355cfb96-ddc5-4911-956c-9705f7557ee5%5C%22%7D%22%0A%20%20%20%7D%2C%0A%20%20%20%22style%22%3A%20%7B%0A%20%20%20%20%20%20%22background-color%22%3A%20%22%23468259%22%2C%0A%20%20%20%20%20%20%22color%22%3A%20%22white%22%2C%0A%20%20%20%20%20%20%22visibility%22%3A%20%22%3Dif((%5B%24Control%5D%20%3D%3D%20'Published')%2C'hidden'%2C'visible')%22%0A%20%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3EMicrosoft%20Power%20Automate%20Community%20Super%20User%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Senior Member

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
Highlighted
Solution

@Claudia_Polders 

the correct code is attached

 

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

 

Thank u

Highlighted

@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

Highlighted

@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