Following on from my last blog post where I started to walkthrough a new Microsoft Flow I created for creating a Microsoft Team for a Project Online project, here is the final part of the Flow. For those that missed part 1, a link can be found below:
In the last post we finished off where the Flow action had sent the request to the Graph API to create the new Team with the new channel and new web site tab and then discussed the 202 response and teamsAsyncOperation process. The next part of the Flow’s job is to get the new Teams webUrl and update the Team URL project level custom field in Project Online.
If the Status Code response is 202 to indicate its been accepted, the Flow them moves on to the next action which is a Parse JSON action to get the Location property from the headers output from the previous HTTP action response:
Then with the Location value another HTTP action is used to call the Graph API:
This performs an HTTP GET request to the Graph API to get the targetResourceLocation property from the newly created Microsoft Team, the Location property from the previous Parse JSON action is used in the URI. The advanced options are the same for all HTTP actions where the Graph API is used so I’ve not expanded this is this post – see part 1 for details.
The next action is another Parse JSON from the previous HTTPTeamResourceLocation HTTP action message body:
This time the targetResourceLocation property is needed. Then the final Graph API call is performed to get the webUrl for the newly create Microsoft Team with another GET request. The targetResourceLocation property from the previous Parse JSON action is used in the URI:
The Flow then moves on to the final Parse JSON action to parse the data returned in the HTTPTeamWebUrl message body:
The Flow now has the new Microsoft Team web URL to update the Project Online project level custom field. The next Flow action is a Checkout project action:
This action will checkout the project, the expression used here for the Project Id property is items(‘Apply_to_each’)[‘ProjectId’].
The next action is a SharePoint HTTP action to perform a REST call to POST to the Project Online CSOM REST API to update the custom field, this uses the same expression in the URI items(‘Apply_to_each’)[‘ProjectId’] :
In the REST call data is sent in the body of the request. This contains the correct internal custom field name for the “Team URL” project field and the custom field value to update the field with, which is the webUrl from the previous Parse JSON 3 action. The internal custom field name would need to be updated to the correct field from your PWA instance.
The final action in this example Flow is Checkin and publish project:
This action will publish the project after updating the custom field and check in the project, the expression used here for the Project Id property is items(‘Apply_to_each’)[‘ProjectId’].
Here are some projects that have been updated and have Microsoft Teams created:
Here is a Team for one of the test project – “1 Paul Mather Test Project 2”:
This Team has the new Project channel and the Project Page web site tab that loads the Project Details Page from PWA:
That’s it, a simple low / no code solution to create Microsoft Teams for Office 365 Project Online projects! To use this in production it needs some additional work to handle various different scenarios but hopefully this is a good starting point for someone looking to do something similar.
I will look to provide a download link for this solution starter Flow in the next few days but will post the link on my blog.