Here is part 7 for my series on extending Microsoft Project for the Web. If you have been following this blog series you might be interested in watching a presentation I did for the recent Collab365 #GlobalCon1 conference where I walked through Project for the Web’s out of the box features then showed examples of how it can be extended using the Power Platform. Session details are here: https://pwmather.wordpress.com/2020/03/02/projectfortheweb-session-at-collab365-globalcon1-the-new-microsoft-project-experience-zero-to-hero-powerplatform-powerapps-powerautomate-msproject/. The conference has ended now but an all access pass it still available: https://partners.collab365.community/13990/48602
In part 7 we look at an option for snapshotting the project data from Project for the Web. If you missed part 6, this covered business process flows and business rules: https://pwmather.wordpress.com/2020/02/06/extending-projectfortheweb-part6-ppm-cds-msdyn365-powerplatform-msproject-powerapps-poweraddicts/
There are many ways to build a snapshot process for Project for the Web but in this example we look at a nice integrated way using the business process flow that was built in part 6. This blog post walks through creating a new action button “Run Flow” on the business process flow stages that can be clicked to create a project snapshot, this new action can be seen here:
To create this, the first step is to create two new entities, one for the Project Snapshots and another for the Task Snapshots, these can be seen below:
These are created to store the snapshot data. Create the replica fields in the new entities based on the data you want to copy from the Project and Task data. For example, in Task Snapshot I created fields for % Complete, Duration, Effort, Finish etc. that match the same data type as the equivalent fields from the Project Tasks entity. Carry out the same process for the new Project Snapshot entity, creating the replica fields in the new entity with matching data types. There are some text fields that are consistent in my two new snapshot entities, these are Snapshot Name which is the Primary Field and SnapshotGUID – you will see how these are used later in the post.
Now we need to create a new Power Automate Flow, it is key the new Flow is part of a solution in the CDS as described here: https://docs.microsoft.com/en-gb/power-automate/overview-solution-flows. The Flow I created can be seen here:
This is triggered using the Common Data Service “When a record is selected” trigger using the entity that my project stage process flow uses. A new variable is then initialized then the new variable value is set using the GUID() expression. These steps can be seen below:
The next step is a Parse JSON action, the entity value is passed in from the trigger action, the schema can be copied from this page here: https://docs.microsoft.com/en-us/power-automate/create-business-process-flow#build-an-instant-flow The next step is a CDS Get Record action, this is used to get the record from the Project Stage Process Flow entity using the BPFInstanceId from the Parse JSON action:
We now know which project the Flow has been run against so we can now get the project record using a CDS “Get Record” action using the Msdyn_Project value from the previous “Get Record” action:
Now we have the project record data we can create a copy of it by creating a new record in the newly created Project Snapshot entity, mapping the data from the previous “Get record Project” action into the correct fields as seen below:
In the Project Snapshot Name field I have used this to reference the stage the project was in when the snapshot was created by passing in the BPFFlowStageLocalizedName value from the Parse JSON action. I also set the SnapshotGUID field to the newGuid variable value. The next step is a CDS “List Records” action, this is used to get the tasks for the associated project from the Project Tasks entity with a filter applied to only return the tasks from the project which the Flow was run against. The filter is “_msdyn_project_value eq ‘Msdyn_Project’” – the project is passed in from the first “Get Record” action:
The final part of the Flow is to create the records in the newly created Task Snapshot entity. To do this, an Apply to each action is needed with the data from the “List records – Project Tasks” passed in. Then inside the loop a CDS “Create a new record” action is used to create the record. Similar to the “Create a new record in the Project Snapshot” action, map the data from the previous action, this time from the “List records – Project Tasks” action into the correct fields as seen below:
In the Snapshot Name field I have used this to reference the stage the project was in when the snapshot was created by passing in the BPFFlowStageLocalizedName value from the Parse JSON action – the same as what we did for the project. I also set the SnapshotGUID field to the newGuid variable value, the same as what we did for the project so that we can link the project snapshot and the task snapshot data together. Save the Flow, the example Flow is now ready.
The Flow now needs to be added as a step in the business process flow associated to the project, in my example it is the “Project Stage Process Flow”. Do this from the business process flow designer:
Expand the Details option on the Stage where you want users to create snapshots like below:
Now with the Components visible on the right hand panel, drag the Flow Step option into the stage steps as seen below:
With the Flow Step still selected, using the Properties panel on the right hand side update the display name, I used “Create Snapshot” and also select the flow by clicking the search option to list the Flows:
Click Apply on the Properties panel. Repeat for all stages as required. Then click the Update button to save and update the business process flow:
That’s it, the snapshot process is built and deployed to our app. In part 8 we will look at using this snapshot process for example projects and viewing the snapshot data that is created.