A long time ago, I wrote this post to check-in projects that have been checked out for too long using Nintex.

With the advent of Microsoft Flow, i wanted to see if we could do the same thing using Microsoft Flow, so what follows is a step-by-step of how to do this in MS Flow.

Lets say the scenario is that you as an admin, want a Flow that will check once every week and check in the projects that have been checked out for more than 5 days.

Here is how the overall flow will look like




Lets discuss each of these steps in detail:

The first step is to set the recurrence as your trigger. This would determine how frequently you want to run this flow. There are several options you can configure for this, with the below as the starting point.

The next step is to collect a list of all the projects in your PWA. For this you would use the List Projects action.

Now that we have the list of the projects, we need to iterate through the list and check which projects are checked out. To check which projects are checked out, we will use the returned property called CheckOutID. This value is equal to 00000000-0000-0000-0000-000000000000 if the project is NOT checked out. (I found this via some trial and error). Alternatively you could use a HTTP Call to SharePoint and check for the Checked out property via oData feed.

Now if the project is NOT checked out, there is no more action to take. However, if the project is checked out, then we will need to determine how long the project has been checked out for. To do this, we will check the date/time difference between the checkedout date and current date. However, since FLOW does not have a easy DateDIff() kind of function, we will need to do this in two steps.

What I have chosen to do is to add 5 days (or whatever your business policy for checked out projects duration is), to the project checked out date, and then compare it with the current date, to determine if the policy is being violated.

Note: I convert both dates into Ticks to be able to use the greater than/less than comparisons.

And finally, once you figured out the project has been checked out for too long, you are ready to take action. In my example, I want to force check the project in, and then send an email to the project owner informing him/her that their project has been checked in.

To retrieve the project owner email, you will need to use Send HTTP Request to SharePoint action, as below:

To read the output of the above action, use the Compose action, as below. for a detail on how to retrieve the information, please refer to my previous blog post using similar actions.

Now, it is time to force check the project in. Use a Send HTTP to SharePoint action, as below.

And finally it is time to send that email. Note that I have put in some dynamic content so that the project manager knows which project and why. You can customize the content as you like.

So, running the flow, assuming there are some projects checked out, the project should be checked in and the owner will see an output like this as email: