Home > Paul Mather, Work > #ProjectOnline Publish all projects using #MSFLow #MicrosoftFlow #PPM #PMOT #Office365 #PowerPlatform part 2

#ProjectOnline Publish all projects using #MSFLow #MicrosoftFlow #PPM #PMOT #Office365 #PowerPlatform part 2

Paul Mather
I am a Project Server and SharePoint consultant but my main focus currently is around Project Server.
I have been working with Project Server for nearly five years since 2007 for a Microsoft Gold Certified Partner in the UK, I have also been awared with the Microsoft Community Contributor Award 2011.
I am also a certified Prince2 Practitioner.

This article has been cross posted from pwmather.wordpress.com (original article)

Following on from my first blog post on Publishing all projects in Project Online using Microsoft Flow, here is the 2nd post. For those that missed the 1st part, it can be found here: https://pwmather.wordpress.com/2018/12/06/projectonline-publish-all-projects-using-msflow-microsoftflow-ppm-pmot-office365-powerplatform-part-1/

In this post we will look at achieving the same publish all functionality but using different actions than we used in the last example. Previously we used the actions available with the Project Online connector, in this example we do not use the Project Online connector when accessing Project Online. The Project Online connector actions used previously to get the projects, check the projects out and then publish and check in the projects have been replaced with a SharePoint action where we can call the Project Online REST APIs. This is to show another example of working with Project Online using Flow. This approach does require an understanding of the Project Online REST APIs but this approach offers so much more capability for Project Online when using Microsoft Flow. The Flow can be seen below:

image

The difference between this Publish all flow and the example from part 1 is that we have replaced all of the Project Online connector native actions with the SharePoint “Send an HTTP Request to SharePoint” action and removed the Filter action as that is not required now. The “Send an HTTP Request to SharePoint” action can be used to work with the Project Online REST CSOM API and the Odata Reporting API directly from Microsoft Flow – this opens up so many more options for working with Project Online using Flow! This Flow assumes you have set up the connection for SharePoint Online using an account that has publish access to all projects and access to the Odata Reporting API in Project Online. This example is still triggered using the schedule action so I wont cover that part. Once triggered, the first action is to get all of the Project Online projects:

image

Enter the Project Online PWA site URL in the Site Address, select the HTTP Method – GET in this case. Then add the Uri, in this case we are using the Odata API to return all project Id’s and filter out the timesheet project but this could be updated to select only projects based on your logic such as projects with a certain custom field value or projects not published in a certain number of days / weeks etc. Then add the HTTP headers as seen. This action will get all of the projects based on the Odata query. Next we need to loop through all of the projects in the array to check them out, publish them then check them back in. To do this we need to use an “Apply to each” action:

image

In the output from the previous step we use body(‘Send_an_HTTP_request_to_SharePoint_-_get_projects’)[‘value’] to use the data from the previous step which is all of our Project Online projects minus the timesheet project in this example. Then for each project in the array we check out the project using another “Send an HTTP request to SharePoint” action:

image

This time the HTTP Method is a POST and the Uri is set to use the REST CSOM API to check out the project. We pass in the ProjectId from the current item in the array using items(‘Apply_to_each’)[‘ProjectId’]

The final action is to publish the project and check it in, this is done using another “Send an HTTP request to SharePoint” action:

image

The HTTP Method is a POST and the Uri is set to use the REST CSOM API to publish the project and check it in – the check in is performed using the true parameter. We pass in the ProjectId from the current item in the array using items(‘Apply_to_each’)[‘ProjectId’]

The final variation of this publish all example is only very slightly different, the only difference is that it is manually triggered rather than on a schedule. We have removed the schedule action and replaced it with a SharePoint trigger to trigger when an item is created on a list:

image

I have a list on my PWA site that only PWA admins can access, here an admin user creates a new item, this then triggers the publish all flow:

image

We then have a history of who triggered the publish all jobs and when.

This post will hopefully give you some ideas on how Microsoft Flow can now really compliment Project Online and offer some scenarios for low / no code customisations.

In the next post we will look at more examples for building low / no code solutions for Project Online using Microsoft Flow.

Advertisement
Categories: Paul Mather, Work Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: