Learn how to trigger an approval process, or any field change, with a single button click.
The Magic Button: Kickstarting Your SharePoint Approvals with Power Automate
With SharePoint, I typically use it for more than just storing files. I love building structured ways to get those files approved. That’s why I love Power Automate, for automating business processes. But how do you start that automated magic? In this post, I’ll walk you through creating a “Start Approval” button, for a smooth and efficient approval process, or any flow for that matter.
Why a Button? User-Initiated Control
Imagine uploading a document to SharePoint, collaborating on it, and then it is ready for review and approval. Instead of manually emailing approvers or updating statuses in multiple places, a single button click initiates the entire automated approval process. This user-initiated control empowers document owners to kick off the workflow when they’re ready for the file to be reviewed and approved.
SharePoint List / Library Configuration
Before we dive into the button itself, create a document library with a few columns for tracking the approval progress:
- Approval Status: A Choice column that reflects the current stage of the approval process. Start with options like:
- New (default)
- Approval 1
- Approval 2
- Approval 3
- Approved
- Rejected
- Approver Columns: Create “people” columns for each approval stage (e.g., “Approver 1,” “Approver 2,” “Approver 3”). These will store the designated approvers for each step.
- Start Approval: This column, a single line of text, will house the JSON formatting code that powers the dynamic button.
Note that if your process is extremely simple and does not entail multiple levels of approval, and you just want the button click to set it as “Approved”, then you can keep it extremely simple and you may not even need a flow.
The Power of JSON: Creating a Dynamic Button “Start Approval”
The “Start Approval” button isn’t a standard SharePoint column. We’ll use the magic of JSON (JavaScript Object Notation) to create a custom button that appears only when needed. This gives us fine-grained control over the button’s visibility and behavior. Here’s the JSON code that makes it all happen:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"style": {
"background-color": "#3E8E41",
"color": "white",
"border-radius": "50px",
"padding": "10px 20px",
"font-size": "14px",
"font-weight": "bold",
"cursor": "pointer",
"width": "auto",
"border": "2px solid #3E8E41",
"min-width": "120px",
"display": "=if([$ApprovalStatus] == 'New' ,'inline', 'none')"
},
"attributes": {
"title": "Click to start the approval process"
},
"txtContent": "Start Approval",
"customRowAction": {
"action": "setValue",
"actionInput": {
"ApprovalStatus": "Approval 1"
}
}
}
Let’s break down this code snippet:
elmType: "div": This creates a container (a<div>element in HTML) to hold our button.children: This array holds the definition of our button.elmType: "button": This creates the button element itself.txtContent: "Start Approval": This sets the text displayed on the button. Customize this to suit your needs (e.g., “Submit for Approval,” “Begin Workflow”).customRowAction: This is where the magic happens. This section defines what happens when the button is clicked:action: "setValue": This specifies that we’re setting the value of a SharePoint column.actionInput: { "ApprovalStatus": "Approval 1" }: This is the crucial part. When the button is clicked, it sets the “ApprovalStatus” column to “Approval 1.” This change in status will trigger our Power Automate flow (more on that in a future post!).
style: This section controls the button’s appearance. You can customize the background color, text color, padding, and other visual aspects.attributes: { "title": "Click to start the approval process" }: This adds a tooltip that appears when hovering over the button.style: { "display": "=if([$ApprovalStatus] == 'New', 'inline', 'none')" }: This is the conditional logic that controls the button’s visibility. Theifstatement checks the value of the “ApprovalStatus” column. If the status is “New,” the button is displayed (display: 'inline'). If the status is anything other than “New,” the button is hidden (display: 'none').
Implementing the JSON: Formatting the “Start Approval” Column
Now that we have our JSON code, let’s add it to our SharePoint list.
1. Go to your document library settings, find the “Start Approval” column, and select Column settings > Format this column.
2. Next, click Advanced mode.
3. Paste your JSON code (from above) into the provided text area and click Save.
Testing the Start Approval Button: Seeing the Magic in Action
With the JSON code in place, upload a new document to your library. Since the Approval Status choice column has been set to have a default status of New, and the button logic says to only display the button when the status is New, you should see the “Start Approval” button appear next to the file. Clicking this button should instantly change the “Approval Status” to “Approval 1.” This change is the key—it’s what you can use to trigger a Power Automate flow to begin the approval process.
Beyond the Basics: Advanced Button Logic
You can extend the button code to create even more dynamic behavior:
- Multiple Conditions: Use
&&(AND) and||(OR) operators to control button visibility based on multiple column values. For example, only show the button if the “Approval Status” is “New” and the file type is PDF. Example:
“display”: “=if([$ApprovalStatus] == ‘New’ || [$File_x0020_Type]==’pdf’, ‘inline’, ‘none’)” - Dynamic Button Text: Use column values within the button text. For example, you could set the button text to “Start Approval for [Document Title]” to provide more context. Example:
“txtContent”: “= ‘Start Approval for ‘ + [$FileLeafRef]” - More Actions: The
customRowActioncan perform more than just setting a column value. You can trigger other actions, like sending an email notification, updating other columns, or even starting a different flow.
This “magic button,” powered by JSON and integrated seamlessly within SharePoint, is the perfect launchpad for your automated approval workflows. By dynamically controlling its visibility and linking it to a status change that triggers Power Automate, you’ve taken the first step towards streamlined and efficient document approvals. In the next post, Trigger conditions for optimizing flow execution, we’ll delve into the trigger condition within Power Automate, exploring how it listens for that document status change and sets the automated approval process in motion!
References
Microsoft’s Use column formatting to customize SharePoint

