Approval Status Writeback
When an approval is completed, update the corresponding SQL row with the approval outcome, approver name, and timestamp. Classic approve/reject writeback pattern.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
FlowLibs - Approval Status Writeback is an intermediate-level Power Automate Cloud Flow that demonstrates the classic approve/reject writeback pattern. When triggered manually, it fetches a record from a SQL Server table, sends it through a Basic approval workflow, and writes the approval outcome (Approved/Rejected), approver name, approval date, and comments back to the original SQL row.
Use Case
Business teams frequently need an approval gate before updating records in a database. This flow provides a reusable pattern for any scenario where a database record requires human approval before its status changes — purchase requests, change requests, access approvals, expense reports, or any record lifecycle that involves a sign-off step.
Flow Architecture
Manually trigger a flow
Manual triggerButton trigger with 3 text inputs: Record_ID, Approval_Title, Approval_Details.
Init varSqlServer
Initialize variableReads SQL server name from env var flowlibs_SqlServerName.
Init varSqlDatabase
Initialize variableReads database name from env var flowlibs_SqlDatabaseName.
Init varSqlTable
Initialize variableReads table name from env var flowlibs_SqlTableName.
Init varApproverEmail
Initialize variableReads approver email from env var flowlibs_ApprovalAssignedToEmail. Steps 2–5 run in parallel.
Get Record By ID
SQL Server — GetItem_V2Fetches the full record by primary key using the Record_ID input.
Compose Approval Details HTML
ComposeBuilds a styled HTML summary showing Record ID, full record data as JSON, and the user's justification text.
Start Approval
Approvals — StartAndWaitForAnApproval (Basic)Sends an approval request to the configured approver with the HTML details body.
Check Approval Outcome
If conditionChecks if outputs('Start_Approval')?['body/outcome'] equals 'Approve'.
- — SQL Server PatchItem_V2 — sets ApprovalStatus='Approved', ApproverName, ApprovalDate=utcNow(), ApproverComments.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_SqlServerName | String | <configure> | Hostname of the SQL Server instance the flow connects to. |
| flowlibs_SqlDatabaseName | String | <configure> | Name of the target database containing the approval records table. |
| flowlibs_SqlTableName | String | <configure> | Name of the table that holds the records being approved/rejected. |
| flowlibs_ApprovalAssignedToEmail | String | approver@yourcompany.com | Email address of the person (or group) who receives approval requests. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| SQL Server | shared_sql | GetItem_V2 (Reads the record by primary key.) PatchItem_V2 (Writes approval/rejection outcome back to the record.) |
| Approvals | shared_approvals | StartAndWaitForAnApproval (Basic approval type.) |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Import the solution
- Import the FlowLibsApprovalStatusWriteback solution zip into your target environment.
- Configure connections
- Authorize the SQL Server and Approvals connection references with appropriate service accounts or user credentials.
- Set environment variable values
- Update all four env vars (flowlibs_SqlServerName, flowlibs_SqlDatabaseName, flowlibs_SqlTableName, flowlibs_ApprovalAssignedToEmail) with your tenant-specific SQL Server details and approver email.
- Ensure your SQL table has the required columns
- The flow writes to ApprovalStatus (text), ApproverName (text), ApprovalDate (datetime), and ApproverComments (text). Add these columns to your target table if they don't already exist.
- Turn on the flow and test
- Switch the flow state from Off to On, click Run, and provide a valid Record_ID, title, and details to verify end-to-end behavior.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Record lookup input
Extracts the Record_ID from the manual trigger input for the SQL GetItem_V2 call.
EXPR.02Approval outcome check
Used in the If condition to branch between the approved and rejected SQL update.
EXPR.03Approver name extraction
Pulls the first responder's display name from the Approvals output for the SQL writeback.
EXPR.04Approver comments
Captures the approver's free-text comments to store alongside the outcome.
EXPR.05Approval timestamp
Records the exact approval/rejection time in UTC, written to the ApprovalDate column.
EXPR.06HTML details body
Serializes the full SQL record as JSON and embeds it inside the HTML approval details.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.