Page approval with changes

Within SharePoint Online it is possible to activate a page approval process. In this article I will show you how to use a security group for the approvers group and include change history in that Power Automate flow.

pageapprovals_button

What does the template offer?

When a new page is submitted for approval everyone on the approvers list will receive an email. Any one on the approvers list can approve the page. When approved, the page will be published for all readers and the approval status of the page will be Approved.

You can configure Page approvals in the settings of the Site Pages library of your site. Microsoft has a Configure page approval using Power Automate support article for this.

When you follow the steps from that support article you will get a cloud flow based on a Microsoft template which will includes steps like:
– Setting the content approval status for the selected page
– Starting a first to respond type of approval task for the approvers
– Handling the outcome of the approval task and either approve or reject the changes for the page

outofthebox_flow

This is a pretty cool out of the box template. However, in some areas I wanted to change it a bit. In this blog I will share the what, why and how of these changes.

Members of a Group

The first thing which I wanted to improve was the list of approvers. I didn’t want to use individual users and configure them in the Start an approval task.

writeupblogtoday

The aim was to use a security group nested within a SharePoint group (site owners).

Highlighted changes

The second part which I wanted to improve was the link in the approval task. The link description says ‘Click here to review the page changes’. But what it actually does is that it directs you the page itself.

writeupblogtoday02

I thought it would be more useful to actually link to the version history of the page and highlight what has changed compared to the previous version. This makes reviewing the page for approval a bit easier.

writeupblogtoday03

Flow Setup

This sample assumes you have already configured the Page approvals for the site.

fourchanges

1. Add a Send an HTTP request action
This action is to retrieve the LoginName of the Security Groups nested within the Site Owners SharePoint Group of a site. Normally the Site Owners Group has an ID of 3 (double check this, just in case). This action is placed directly after the Set content approval status – Pending action and before the Start an approval action.

sendanhttprequest_siteowners

a. Select your preferred site in the Site Address
b. Use the GET method
c. Use the URI from the code snippet below

d. Use the Headers from the code snippet below

2. Add a Send an HTTP request action.
This action is using the loginName value of the first found security group from the previous action. It uses slice, add & indexOf functions to find and retrieve the id of the security group from that loginName value. The List group members method of the Graph API is used to retrieve the members of the group. A microsoft.graph.user OData cast is used to only retrieve members of that group which are of type user (members of type group aka nested groups are excluded)

sendanhttprequest_slicemembers

a. Use the URI from the code snippet below

b. Use the GET method

3. Add a Select action.
This action is used to only select the e-mail addresses values of the returned members.

select_mail_sgmembers

a. Use the body/value from the Send an HTTP request action of step 2 in the From field (via the Expression tab)

b. Switch the Map field to text mode
c. Add the code snippet below in the Map field

4. Update the Start an Approval action.
Only the Assigned To and and Item Link fields will be updated in this action. The expression in the Assigned To field uses a join function to turn the array into a semi colon separated string value. In the Item link field concat, formatnumber, sub & float functions are used to generate a ?versionCompare hyperlink. The syntax of that link is:
NameOfPage.aspx?versionCompareFrom=2.0&versionCompareTo=2.1

clickheretoreviewthepagechanges

a. Use the code snippet below for the Assigned To field

b. Use the code snippet below for the Item Link field

That is it for changing the template setup.

Happy testing!

You may also like...

1 Response

  1. Pritam says:

    Hi,

    Need your kind guidance in completing my task

    I have created a Leave Request app without powerapp template.

    I have two tables (screenshot attached).

    Everything running smoothly, leave apply, email notification for approval, once approved, notify user.

    Last thing I want, to update LeaveBalance Table (AppliedLeave) field with the value of TotalDays from LeaveApplication table.

    Kindly help ASAP.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.