Whenever there is a need to design an automated solution for driving the approval and conversion process of documents in SharePoint Online, One drive etc., we look at the traditional Approvals – Start an approval template in Power Automate.
This traditional approach is simply not up to the task anymore and, to be honest, it isn’t a time friendly solution either. Beyond it’s time drain, it has too many components that need to be coordinated and it’s driven via emails, never a good sign when you want to build a robust and reliable automated solution.
Good news, now there is a way to make this process streamlined, simple, quick, and efficient by using Adaptive Cards in The Microsoft Teams channel of a Power Automate (Flow) solution. This post will describe how to make use of an Adaptive Card in The Microsoft Teams channel to drive the document approval and conversion process in SharePoint Online without using emails.
Adaptive Cards are platform-agnostic snippets of UI, authored in JSON, that apps and services can openly exchange.When delivered to a specific app, the JSON is transformed into native UI that automatically adapts to its surroundings.It helps design and integrate light-weight UI for all major platforms and frameworks.
The purpose of this post is not to describe the design of Adaptive Cards, but if you would like a quick primer on the design of Adaptive Cards, please use the designer made available over here.
I have also included a video tutorial at the end just in case you want to follow.
Here is the link to my Youtube channel-
https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ?sub_confirmation=1
Before we begin, please make sure the following prerequisites are in place:
Configurations on the SharePoint end-
One of the most important parts in the Document Approval process is storing the responses associated with the approval, so that the end user(s) who actually works on the document is updated on the current status of the document.
In order to keep the user(s) updated, we’re going to create some columns in the SharePoint source library so that we can display the following –
As you can see in the image below, I have added three columns with the names File Status, Approved/Rejected By, and Approval Comments.
Now that SharePoint source library is configured, let’s go ahead and start configuring our Power Automate solution.
Step 1 – Trigger
Step 2 – Get File Content
Step 3 – Get File Metadata
Step 4 – Send an HTTP request to SharePoint
_api/Web/Lists/GetByTitle(‘your document library name’)/Items?$select=EncodedAbsUrl,FileLeafRef,ID&$Filter=Id eq [‘ItemId’]
Step 5 – Initialize Variable
Step 6 – Parse JSON
{ "type": "object", "properties": { "value": { "type": "array", "items": { "type": "object", "properties": { "Id": { "type": "integer" }, "FileLeafRef": { "type": "string" }, "ID": { "type": "integer" }, "EncodedAbsUrl": { "type": "string" } }, "required": [ "Id", "FileLeafRef", "ID", "EncodedAbsUrl" ] } } } }
Step 7 – Apply to each
Step 8 – Post an Adaptive Card to a Teams channel and wait for a response
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": 2,
"items": [
{
"type": "TextBlock",
"text": "Please Approve or Reject this document",
"weight": "Bolder",
"size": "Large",
"spacing": "ExtraLarge",
"separator": true,
"horizontalAlignment": "Center",
"height": "stretch",
"color": "Accent"
},
{
"type": "TextBlock",
"text": "Approved By",
"wrap": true
},
{
"type": "Input.Text",
"id": "myName",
"placeholder": "Approver's full name"
},
{
"type": "TextBlock",
"text": "Email Address",
"wrap": true
},
{
"type": "Input.Text",
"id": "myEmail",
"placeholder": "abc@example.com",
"style": "Email"
},
{
"type": "TextBlock",
"text": "Approval/Reject Comments",
"wrap": true
},
{
"type": "Input.Text",
"id": "commentsId",
"placeholder": ""
}
]
}
]
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "View document",
"url": "google.com"
},
{
"type": "Action.Submit",
"title": "Approve",
"size": "Small",
"style": "positive"
},
{
"type": "Action.Submit",
"title": "Reject",
"size": "Small",
"style": "destructive"
}
]
}
Note – At this point, you will need to run the Power Automate once ,or the different values exposed by ‘Post an Adaptive Card to Teams channel‘ will not be made available in the ‘Add Dynamic Content‘ section which we need in the steps that follow right next.
Step 9 – Condition
Step 10 – Outcome of Step 9 is true, If yes
Step 10 – Outcome of Step 9 is false, If No
Perfect, go ahead and run the Power Automate now by uploading a File in the source library, fill-in the Adaptive card and choose either Approve or Reject (I have chosen Approve here), but Reject proves the rejected file will not be converted to PDF..
In a short time, you will see that the File properties have been updated based on your responses in the Adaptive card and a PDF File has been created successfully.
Outputs-
File uploaded for Approval –
Adaptive Card received in Team channel –
File properties updated and File converted to PDF –
File Converted to PDF –
Video Tutorial -
Keep checking this blog for exciting new articles about Power Automate, SharePoint Online, Power Apps, as well as document conversion and manipulation using The Muhimbi PDF Converter.