Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Format a Flow Trigger Button in List to Run a Flow Based on Conditions

Like (0) ShareShare
ReportReport
Posted on 8 Jun 2020 10:26:16 by 28

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,

 

 

  • KurtEichler3000 Profile Picture
    12 on 21 Aug 2020 at 15:23:54
    Re: Format a Flow Trigger Button in List to Run a Flow Based on Conditions

    works great!  Thanks for the assist.

  • RobElliott Profile Picture
    10,136 Super User 2025 Season 1 on 21 Aug 2020 at 14:53:46
    Re: Format a Flow Trigger Button in List to Run a Flow Based on Conditions

    @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:

     

    buttonNotRun.png

     

    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.

  • KurtEichler3000 Profile Picture
    12 on 20 Aug 2020 at 19:53:08
    Re: Format a Flow Trigger Button in List to Run a Flow Based on Conditions

    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')"
    }
    ]
    }

  • WAM2 Profile Picture
    28 on 09 Jun 2020 at 17:06:00
    Re: Format a Flow Trigger Button in List to Run a Flow Based on Conditions

    @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.

    unnamed.png

  • Verified answer
    RobElliott Profile Picture
    10,136 Super User 2025 Season 1 on 09 Jun 2020 at 16:40:42
    Re: Format a Flow Trigger Button in List to Run a Flow Based on Conditions

    @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.

  • WAM2 Profile Picture
    28 on 09 Jun 2020 at 16:32:49
    Re: Format a Flow Trigger Button in List to Run a Flow Based on Conditions

    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')"
    
     }
    
    }
  • RobElliott Profile Picture
    10,136 Super User 2025 Season 1 on 09 Jun 2020 at 16:12:18
    Re: Format a Flow Trigger Button in List to Run a Flow Based on Conditions

    @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.

  • WAM2 Profile Picture
    28 on 09 Jun 2020 at 15:46:55
    Re: Format a Flow Trigger Button in List to Run a Flow Based on Conditions

    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

  • SteveYao Profile Picture
    on 08 Jun 2020 at 23:40:11
    Re: Format a Flow Trigger Button in List to Run a Flow Based on Conditions

    Hi @WAM2 

     

    Have you referred to this documentation?

    https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Automate - Building Flows

#1
David_MA Profile Picture

David_MA 276 Super User 2025 Season 1

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 245 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 212

Overall leaderboard
Loading started