Creating new Projects based on EPTs in #Office365 #ProjectOnline using #MicrosoftFlow #PPM #PowerPlatform #REST #MSProject #ProjectManagement
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) |
When creating projects in Office 365 Project Online you can create projects based on different types known as Enterprise Project Types, here is a link on setting these up: https://pwmather.wordpress.com/2014/01/27/getting-started-with-projectonline-part-5-ps2013-office365-project-ppm-sharepointonline-pm/ Creating a project via PWA enables you to select the correct EPT for your type of project. When creating a project programmatically you can also set the correct EPT. The default “Creates new project” Project Online Microsoft Flow action does not provide the ability to set the Enterprise Project Type, it will just use the default type. The action can be seen below:
The easy solution is to use the SharePoint HTTP action to use the Project Online CSOM REST API as seen below in this example:
This example is very much hard coded and manual when setting the EPT value, project names etc. In a real world example these would be set from the source application requesting to create a project, but the process is the same. So assuming the source application had set the variable to Marketing as seen below, the switch action would then check the value in the variable:
In the switch action you would have switch cases for each EPT you have / want to use. In my test PWA instance I have 3 EPTs I wanted to use – Enterprise Project, Marketing and R&D:
I have set the Switch action to have 3 cases, 2 to match the the EPT values for Marketing and RD then the 3rd as a catch all that uses the default Enterprise Project EPT.
In this example case the variable value is Marketing so the Switch action would then use the CreateMarketingProject action seen below – this is the SharePoint HTTP action:
Here we call the _api/ProjectServer/Project/Add project API with a POST request and pass JSON in the body that details how to create the project as seen below:
The key parameter value here for the EPT is the EnterpriseProjectTypeId, in this case this is the GUID for the Marketing EPT as seen below:
The EnterpriseProjectTypeId GUIDs are different in the other cases within the Switch action so that the projects are created using the correct EPT. Without passing in the EnterpriseProjectTypeId, the project would create using the default EPT. A simple solution for creating the correct project type in Project Online using the Power Platform application Microsoft Flow.