Power Automate : Check if the SharePoint Site Page is published using HTTP Action and Version Number verification

Problem Statement

In order to create a flow that will do some logic implementation only when a Page is published in the Site Pages library, we need to know if it is a major or minor version. However there is no straight forward single action to check if the document is in major version(hence Published) or if it is a minor version which means it is still in Draft state.

Solution

In order to work around the situation , we can check the Version number and see if it is of the format 1.0,2.0 and so on. A .0 notation ensures that it is a published major version or else if the version number is 1.2,2.1 and so on we can identify that it is a minor version and hence not published

Implement the Published Version Checking Flow

Before we start with the flow creation, lets ensure that the major/minor versioning is enabled in the library settings

Now lets head over to Power Automate and create a flow with the trigger action “When a file is created or modified”. We will have to manually add the Site Pages in the Library name section as it does not get auto populated

Now we need to get the version number of the file which is available as a dynamic property. Hence we will have to issue an HTTP Request and retrieve the version number as shown below :

Now lets initialize a variable which will hold the version number retrieved from the body of the above request. Add the below expression to the value field which will get the Version Number from the body .

body('Send_an_HTTP_request_to_SharePoint')?['d']?['OData__UIVersionString']

We will now check the variable which contains the version number and will use an Condition to see if the version number has .0 which indicates that it is a major version or else it will be a minor version. We will update the result – Major/Minor version to a custom field that we have added to the library.

Lets add the condition that checks if the version number ends with .0 and will update the Column with Major/Minor version accordingly

Test the implementation

Now lets test the flow by creating a site page. On saving it , it will be saved as a minor version . This should ideally kick start the flow and will save the value minor version to the custom column.

After a while we can see that the flow has run and has updated the column with value Minor version 

Now lets head over to the page and Publish it which will convert it to a major version.

Heading over to the flow page, we can see that the flow has run successfully

If we go to the site pages, there as well we can see that the custom column has been set with the major version value.

Summary

Thus we saw how to check the version number of a document and decide if it is a major/minor version and hence if it is published or not