#Project Roadmap #PowerBI report pack #PPM #ProjectManagement #MSProject #ProjectOnline #Office365 #PowerPlatform #Dynamics365

January 30, 2019 at 12:19 am | Posted in Administration, Functionality, Information, Reporting | 3 Comments
Tags: , , , , , , , ,

I have released a solution starter report pack for Project Roadmap, this follows on from a mini series of blog posts on the Roadmap backend CDS database / app. The final post in that series can be found here: https://pwmather.wordpress.com/2019/01/22/project-roadmap-cds-app-overview-ppm-projectmanagement-msproject-projectonline-office365-powerplatform-dynamics365-powerbi-part-3/

As mentioned in that post, I would release the Power BI report pack I created. This report pack can be downloaded from the link below:

https://gallery.technet.microsoft.com/Roadmap-Power-BI-Report-8eaae91e

This report pack consists of 3 reports for Project Roadmap, these reports can be seen below:

Roadmap Summary page:

image

Roadmap Detail page:

image

Roadmap Sync Admin page:

image

Once downloaded, the report pack CDS data source will need to be updated to point to your target Project Roadmap environment. To do this you will need the Power BI desktop tool which is a free download here: https://powerbi.microsoft.com/en-us/desktop

Open the downloaded PWMatherRoadmapReport.pbit template file in Power BI Desktop and follow the steps below to point the CDS data source to your Project Roadmap environment:

  • When prompted, enter the correct CDS URL for the Project Roadmap environment:

image

image

    • I created a new role in the Dynamics 365 instance where Roadmap is deployed – access the Dynamics 365 admin center from the Office 365 Admin center using the Global Admin account. Open the default Dynamics 365 instance (this is where Roadmap is deployed to) then click Settings > Security > Security Roles > New. I gave the new role Read access at the business unit level to the 4 Roadmap entities used in the report:

image

    • I then accessed the user account from the Dynamics Security admin in the Users page then assigned the new role to this account using the Manage Roles option. Other roles and role assignments are as per the default settings:

image

    • Now the report will be able to access and load the data.
  • The report will update with the data from your Project Roadmap environment – this might take a few minutes.
  • Save the report.
  • Publish the report to the Power BI service and distribute / share as required.

Your Office 365 administrator / Dynamics 365 administrator will be able to help you out with the correct user account to use as they will probably have a preferred approach to granting access that might be different to the way I have done it here. Or they might want to set up this report, publish to Power BI and give you access via the Power BI service.

This does use the Power BI Common Data Service for Apps (Beta) connector – so this connector could change when released and the report might require some re-work.

I hope you like it and find it useful.

Advertisements

#Project Roadmap #CDS #App Overview #PPM #ProjectManagement #MSProject #ProjectOnline #Office365 #PowerPlatform #Dynamics365 #PowerBI Part 3

January 22, 2019 at 7:39 pm | Posted in Administration, Configuration, Functionality, Information, Reporting | 2 Comments
Tags: , , , , , , , ,

This post follows on from part 2: https://pwmather.wordpress.com/2019/01/07/project-roadmap-cds-app-overview-ppm-projectmanagement-msproject-projectonline-office365-powerplatform-dynamics365-part-2/ In Part 2 we reviewed the fields and looks looked at the data used by the Roadmap application. In this post we will continue with the Power BI report that was started in part 2. I have made some changes following on from the last post if you have been following and creating the Power BI report. The queries I have can be seen below:

image

Here are the query connection details:

  • Roadmaps queries msdyn_roadmaps but filter to only return roadmaps
  • RoadmapItems queries msdyn_roadmapitems but filtered to only return roadmap items
  • RoadmapRows queries msdyn_roadmaps but filter to only return rows
  • RoadmapRowItems queries msdyn_roadmapitems but filtered to only return row items
  • RoadmapItemLinks queries msdyn_roadmapitemlinks
  • RoadmapRowLinks queries msdyn_roadmaprowlinks

I have also used the Power Query editor options to remove fields I do not need, renamed fields etc. but that is standard Power BI functionality.

Then the following relationships have been set up between these tables:

image

Or the visual view:

image

Now this Power BI file is ready to start creating the reports. Here are some screen shots of example reports:

image

image

I will be releasing the Power BI file to download later this week that can be used as a solution starter for your Project Roadmap reporting. I will then create a blog post on how you can bring in other data from Project Online into the Power BI file.

#ProjectOnline PWA Project Details Page integration with Project Roadmap #Office365 #PPM #PowerPlatform #MSFlow

January 16, 2019 at 7:22 pm | Posted in Administration, Functionality, Information, Reporting | 1 Comment
Tags: , , , , ,

As you are probably aware by now, the new Roadmap feature is live in Project Home as detailed in this blog post: https://pwmather.wordpress.com/2018/12/19/project-roadmap-is-live-ppm-projectmanagement-msproject-projectonline-office365-powerplatfom/ This post covers a new button that would have appeared in your Project Online PWA instance:

image

This new Add to Roadmap button is on the Task tab on Schedule Project Detail Page. This enables you to add published tasks to a project roadmap directly in Project Online PWA without having to navigate away to the Project Home, open the Roadmap then adding the tasks via the Roadmap interface.

When the current project is linked to a roadmap row with at least one task selected (you can select multiple), clicking this will load a modal pop up:

image

You will then need to select the correct Roadmap and Row using the dropdowns. Only Roadmaps and Rows will appear where the current project is already linked. Here is one Roadmap where this project is linked:

image

I’ve selected the Deployment task then clicked the Add to Roadmap button then selected the Roadmap and Row as seen below:

image

Clicking Add will start the process to add the task:

image

Once completed you will see the added to roadmap message as below with a clickable link to the roadmap:

image

Accessing the roadmap will now show the new task added:

image

If you try the Add to Roadmap button for a project that is not linked to a Project Roadmap you will see this modal popup:

image

A great enhancement to Project Online!

#Project Roadmap #CDS #App Overview #PPM #ProjectManagement #MSProject #ProjectOnline #Office365 #PowerPlatform #Dynamics365 Part 2

January 7, 2019 at 6:03 pm | Posted in Administration, Configuration, Functionality, Information | 3 Comments
Tags: , , , , , , ,

This post follows on from part 1: https://pwmather.wordpress.com/2019/01/01/project-roadmap-cds-app-overview-ppm-projectmanagement-msproject-projectonline-office365-powerplatfom-dynamics365-part-1/ In part 1 we had a quick overview of the solutions used in the CDS app for the Roadmap service. In this post we will look at the fields used by the Roadmap service and take a look at some of the data in the Portfolio Service CDS database. As you know, this new feature is known as Roadmap to the end users, but the backend is known as the Portfolio Service, hence both names being used here.

Firstly we will have a look at some of the entities and field definitions from the Portfolio Service solution PowerApps admin interface that we briefly accessed at the end of part 1:

image

As you can see from the screen shot above, there are 6 entities deployed in the Portfolio Service solution. Each of these entities have various other artefacts such as views, keys, fields etc. For this post, we will just look at the fields. We wont explore all of the entities or all of the fields in each entity, but we will look at some of the key entities and fields used by the Roadmap service.

Firstly we will look at the Roadmap entity in the PowerApps portal:

image

You can scroll along the grid to see the properties such as description etc. This entity contains the roadmap details – the roadmap properties and rows added to the roadmap. Some of the key fields here for us as end users for reporting etc. are:

  • msdyn_name – this field will contain the Roadmap name and the row name
  • msdyn_type – this is used to determine the type – either a Roadmap which is type 0 or a row which is type 1
  • msdyn_roadmapid – this is the roadmap / row GUID
  • msdyn_parentroadmapid – this is contains the roadmap GUID for the rows added to a roadmap
  • msdyn_groupaadid – this is the associated Office 365 group ID

The next entity is the Roadmap Item:

image

This entity contains the roadmap item details – items added to rows on the roadmap and items added directly to the roadmap like key dates. Some key fields are:

  • msdyn_name – this field will contain item or key date name
  • msdyn_duedate – this field will contain the due date for row items
  • msdyn_startdate – this field will contain the start date for row items
  • msdyn_status – this is the status for the item such as At Risk, On Track etc.
  • msdyn_type – this is used to determine the type – either a key date which is type 0 or a phase which is type 1
  • msdyn_roadmapid – this is the roadmap / row GUID
  • msdyn_roadmapitemid – this contains the roadmap item GUID

The next entity is the Roadmap Item Link:

image

This entity contains the roadmap item link details – items added to rows on the roadmap that are linked to external projects (Project Online or Azure Boards currently). Some key fields are:

  • msdyn_externalname – this field will contain the external task name
  • msdyn_externalduedate – this field will contain the external due date for row items
  • msdyn_externalprojecttaskid – this is the external task GUID from the external project
  • msdyn_externalstartdate – this field will contain the external start date for row items
  • msdyn_externaltype – this is used to determine the type – either a key date which is type 0 or a phase which is type 1
  • msdyn_externalurl – this is the link to the external project
  • msdyn_roadmapid – this is the roadmap row GUID
  • msdyn_roadmapitemid – this contains the roadmap item GUID
  • msdyn_roadmapitemlinkid – this contains the roadmap item link GUID

The final entity that we will look at is the Roadmap Row Link:

image

This entity contains the roadmap row link details – rows on the roadmap that are linked to external projects (Project Online or Azure Boards currently). Some key fields are:

  • msdyn_externalname – this field will contain the external project name
  • msdyn_externalprojectid – this is the project GUID from the external project
  • msdyn_externalurl – this is the link to the external project
  • msdyn_refreshenddate – this is the finish time the external project last synchronised with the CDS data via the Flow
  • msdyn_refreshstartdate – this is the start time the external project last synchronised with the CDS data via the Flow
  • msdyn_roadmapid – this is the roadmap row GUID
  • msdyn_roadmaprowlinkid – this contains the roadmap row link GUID

Lets explore the data in the Roadmap entity. There are several ways in which we can do this, in code using the Organization Service or the Web API: https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/work-with-data-cds or there is a Connector for Power BI: https://powerapps.microsoft.com/en-us/blog/cds-for-apps-powerbi/ For this I will use Power Query in Power BI but also show you how to access the Web API too. To access the Roadmap data in Power BI you will need the server URL. There are at least two ways (probably more) to get the correct server URL for the CDS Roadmap uses. Firstly via the Office 365 Admin Center using the steps below:

Access the Office 365 Admin Center > Admin Centers > Dynamics 365:

image

Then click open on the correct instance and you will see the server URL in the URL bar:

image

The other way, if you do not have access to the Admin Center is by using the browser dev tools. Access Project Home > Press F12 / open the dev tools > Access a Roadmap > In the Network tab, find the network call GetCdsEndpoint then check the Response, you will see a cdsurl property:

image

Once you have the server URL you can either use the Power BI connector or the Web API. The the simplest way to demo viewing this data using the Web API is via the Browser. In this example. Add the following to the end of the server URL: /api/data/v9.1 – you can use a different version, at the time of writing 9.1 was the latest on my tenant. Going to the root Web API URL will return the JSON for all of the entities available. Append the entity that you want to access to the end of the URL and you will see all of the data available in the entity:

image

As the Web API implements the OData protocol you can use the standard query options such as $select or $filter. Here I’m just selecting the name and type from the roadmaps entity:

https://org05724544.crm11.dynamics.com/api/data/v9.1/msdyn_roadmaps()?$select=msdyn_name,msdyn_type

image

Here I’m filtering for roadmaps only as the roadmaps entity contains roadmaps and rows:

https://org05724544.crm11.dynamics.com/api/data/v9.1/msdyn_roadmaps()?$filter=msdyn_type eq 0

image

To easily make sense of the data you need to format the JSON. Power BI is easier to visualise the data.

In Power BI click Get Data > More > Online Services > Common Data Service for App (Beta):

image

Select it then press connect. Accept the warning about being a preview connector (something to be aware of!). Now enter the server URL:

image

Now you can see all of the tables / entities that are in this CDS service, for the purpose of this blog post I will just expand Entities then select Roadmap, Roadmap Item, Roadmap Item Link and Roadmap Row Link:

image

Then click Edit to load these in the query editor. I’ve removed some of the default fields to clean up the data. Here is one of my roadmaps from the msdyn_roadmap table via Power Query in Power BI:

image

Here is a row from my roadmap:

image

Here is a key date added to my roadmap from the msdyn_roadmapitem table:

image

Here is a task (known as a phase in Roadmap) added to a row in the roadmap:

image

Here is a milestone (known as a key date in Roadmap) added to a row in the roadmap:

image

Here is an item link for a task linked to a row in Roadmap from msdyn_roadmapitemlink table:

image

Here is an row link for a project linked to a row in Roadmap from msdyn_roadmaprowlink table:

image

In the final part of this mini series, we will look at following on from this and creating a simple report in Power BI for the Roadmap data and bring in some Project Online data.

#ProjectOnline Snapshot / data to #SharePoint list using #MSFLow #MicrosoftFlow #PPM #PMOT #Office365 #PowerPlatform

December 14, 2018 at 10:00 pm | Posted in Add-on, Administration, Configuration, Customisation, Functionality, Information, Reporting, Workflow | 2 Comments
Tags: , , , , , , , ,

Next in my series of posts on using Microsoft Flow with Project Online is capturing Project Online data into a SharePoint list, this is a useful scenario for simple snapshot requirements. For example, if you want to snapshot some key project level data, the easiest place to store this data is in a SharePoint list. I have blogged simple code examples before that do this: https://pwmather.wordpress.com/2016/08/26/projectonline-data-capture-snapshot-capability-with-powershell-sharepoint-office365-ppm-bi/ & https://pwmather.wordpress.com/2018/01/27/projectonline-project-level-html-fields-to-a-sharepoint-list-powershell-ppm-office365/ Whilst these approaches work, the PowerShell does need to be run from somewhere, a server / Azure Function etc. This post provides the same end result with Project Online data in a SharePoint list but all from a Microsoft Flow. The Flow can be seen below:

image

This simple example makes use of the recurrence trigger to schedule the process, the “Send an HTTP Request to SharePoint” action to get the project data from Project Online and a SharePoint create item action inside an Apply to each loop. We will walkthrough the actions later in the post.

Firstly, the SharePoint list was created:

image

This was created in my Project Online Project Web App site collection. I created SharePoint columns on this list for each of the fields I wanted to capture from my Project Online dataset. As this is just an example, the number of fields and data is quite limited. Now back to the Flow. We will skip over the recurrence trigger to the first action that gets the Project Online data, this just uses the “Send an HTTP Request to SharePoint” action to call the Project Online OData REST API so that we can easily get all of the Project Online data. In this example we are accessing the Projects endpoint in this API and selecting a few example project level fields including an example custom field:

image

This action will get all of the data based on the Odata query used in the Uri input. We wont cover all of the settings here in this post as I covered this in the last post found here: https://pwmather.wordpress.com/2018/12/12/projectonline-publish-all-projects-using-msflow-microsoftflow-ppm-pmot-office365-powerplatform-part-2/

Next we need to loop through all of the projects in the results array to create a SharePoint list item for each project. To do this we need to use an “Apply to each” action:

image

In the output from the previous step we use body(‘ReadallProjects’)[‘value’] to use the data from the previous step which is all of our Project Online projects with some data minus the timesheet project in this example. Then for each project in the array we create a list item on our target SharePoint list using the create item action. In the create item action we just map the data from the array to the correct list column. The Project Online fields are accessed using an expression, for example for ProjectCost in this example Flow the expression is items(‘Apply_to_each’)[‘ProjectCost’] where apply to each is the name of the action and ProjectCost is the field / property in the results from the Odata query.

Once this Flow runs a few times you can then easily create snapshot / trend reports or even extend the SharePoint view to show what you need:

image

As you can see in this example, I’ve updated the SharePoint view to show the RAG icon in the Overall RAG column rather than the text value. This is very simple with the column formatting options available with the SharePoint modern UI using JSON.

Another example of extending Project Online with low / no code solutions in Office 365.

There will be further example solutions built for Project Online using Microsoft Flow in later posts.

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

December 12, 2018 at 9:00 pm | Posted in Administration, Configuration, Customisation, Functionality, Information, Workflow | 4 Comments
Tags: , , , , , , ,

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.

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

December 6, 2018 at 12:00 am | Posted in Add-on, Administration, Configuration, Customisation, Functionality, Information, Performance, Reporting, Workflow | 1 Comment
Tags: , , , , ,

I recently had the opportunity to present at a Microsoft Tech Sync session where I presented a session on Project Online and Flow. During this session gave examples of how Microsoft Flow compliments Project Online by enabling no / low code solutions to extend the Project Online features. I plan to do several blog posts over the next month or so where I will share some of these Microsoft Flows. Hopefully this will give you some ideas of how Microsoft Flow can be used to simplify some of those customisations for Project Online.

The first Flow example I want to share with you is a publish all projects flow. I have published examples before for Project Server and Project Online as found here:

These all required a basic understanding of the Project Server / Project Online APIs and somewhere to run the code from – I thought this would be a good example to move over to a Microsoft Flow. In this blog post I will walkthrough the first example I have for publishing all projects as seen here:

image

This is built using only actions from the Project Online connector in Flow – so there is no need to understand the Project Online APIs! This Flow assumes you have setup the connection to Project Online using an account that has publish access to all projects. This Flow is triggered using a schedule as seen here:

image

When this Flow is triggered, the first action is to get all the Project Online projects using the List Projects action:

image

All you need to do is provide the PWA site URL. This List Projects action also includes project templates so these need to be filtered out, to do this we filter the results returned from the List Projects action using a Filter Array action:

image

In the From field we enter body(‘List_projects’)[‘value’] to get the data from the previous action, which in this case is the List projects action. In the filter we use item()[‘ProjectType’] is not equal to 1, Project Type 1 being the Project Templates. In advanced edit mode it looks like this:

image

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(‘Filter_array’) to use the data from the previous step which is all of our Project Online projects minus the project templates. Then for each project in the array we check out the project using the default Checkout project action:

image

Enter the Project Online PWA URL then in the Project Id property pass in the Project ID from the current item in the array using items(‘Apply_to_each’)[‘Id’]

The final action is to publish the project and check it in, this is done using the default Checkin and publish project action:

image

Enter the Project Online PWA URL then in the Project Id property pass in the Project ID from the current item in the array using items(‘Apply_to_each’)[‘Id’]

That is it, when this flow executes it will publish all of your Project Online projects. A simple no code serverless solution!

In part 2 we will look at two other variations for publishing all projects in Office 365 Project Online using Microsoft Flow.

#MicrosoftForms and #MicrosoftFlow for #ProjectOnline #PPM project reviews #O365 #SharePoint #PMOT

February 11, 2018 at 10:47 pm | Posted in Add-on, Administration, Configuration, Customisation, Functionality, Information | Comments Off on #MicrosoftForms and #MicrosoftFlow for #ProjectOnline #PPM project reviews #O365 #SharePoint #PMOT
Tags: , , , ,

Most projects at some point have some kind of review such as a stakeholder review or project closure review. As Project Online is built on SharePoint there are many ways that this can be achieved but in this blog post we will look at making use of Microsoft Forms to design those reviews, Microsoft Flow to capture the responses for the reviews and SharePoint Online to store the data in a list in the Project Web App site collection. As Project Online is built in the Microsoft Office 365 cloud there are lots of great features that you can make use of, Forms seemed a good fit for a project review.

Firstly access https://forms.office.com/ to get started with your review form. Please note Forms is currently in Preview. Click the New Form button:

image

This will load the form designer:

image

You can use the Theme button to select a theme or upload your own:

image

Enter a form title and description:

image

Then click the Add question button:

image

Select the type of response your question requires, notice the two additional options on the ellipsis at the end. Depending on the type of question selected, that will determine the control used on the form. Design the form as required, for this blog post, here is my very simple form:

image 

Now on my Project Online PWA site in SharePoint Online I have created a list that contains columns for each of my questions:

image

The next step is to access Microsoft Flow and click create from template:

image

This blog post assumes you have already set up the connection to your SharePoint Online tenant in Microsoft Flow.

Search for forms and the existing templates for Forms will be loaded:

image

For this example we just need the first one “Record form responses in SharePoint”, click Continue:

SNAGHTMLfdf7de8

Give the Flow a name then select the correct form in the “When a new response is submitted” Flow action:

image

Then again in the “Get response details” Flow action:

image

Then select / type / paste the SharePoint site URL and select the list created in the “Create item” Flow action:

SNAGHTMLfe28386

Then map the responses from the form to the SharePoint list columns in the “Create item” Flow action:

SNAGHTMLfecca34

Save the Flow.

Now back in Forms, access the Form then click the ellipsis then Settings:

image

On the form settings, set who can respond to the form, in this example I only want people in my organisation to response and I set it to record their name:

image

Now click the Share button to get the form URL to send to the relevant users or add in the Project Web App site. For example, if you were creating a project closure review form or stakeholder review form you might add this to a certain Project Detail Page that is only visible at a certain stage of the project lifecycle.

Once users respond you will see the flow runs in the run history and you will also see the responses on the target SharePoint list. See some example responses below:

image 

Do be aware of the SharePoint list access – you might want to restrict access to this list!

Running #ProjectOnline #PowerShell in #Azure using #AzureFunctions #PPM #Cloud #Flow #LogicApp Part2

August 1, 2017 at 4:32 pm | Posted in Add-on, Administration, Configuration, Customisation, Functionality, Information, PowerShell, Workflow | Comments Off on Running #ProjectOnline #PowerShell in #Azure using #AzureFunctions #PPM #Cloud #Flow #LogicApp Part2
Tags: , , , , , , ,

Following on from part 1 where I introduced the idea of automating certain Microsoft 365 PPM Project Online customisations using PowerShell, Microsoft Flow / Azure Logic Apps and Azure Functions, in part 2 I will set up an example automation for creating a Project Online event driven snapshot application on project published without having to set up any server or write any complied code! If you missed part 1 where this concept was introduced, see the link below:

https://pwmather.wordpress.com/2017/07/28/running-projectonline-powershell-in-azure-using-azurefunctions-ppm-cloud-flow-logicapp-part1/

Firstly I created an Azure Function app in my Azure subscription then created a new function based on the HttpTrigger – PowerShell template:

image

Give the function a name and set the Authorisation level – set the authorisation level to the correct setting for your function. Click Create. For details on Azure Functions, start here: https://docs.microsoft.com/en-us/azure/azure-functions/

You will then be presented with the function and sample code:

image

We will now create the PowerShell script to create the snapshot. This is based on a script I published a while back: https://pwmather.wordpress.com/2016/08/26/projectonline-data-capture-snapshot-capability-with-powershell-sharepoint-office365-ppm-bi/

The script has been updated to work in an Azure Function but also modified to use a parameter so that it only captures data for the published project, the PowerShell script can be seen further on in the post.

Firstly upload the SharePoint CSOM DLLs using the upload button:

image

I used the SharePoint CSOM DLLs from the SharePoint Online Management Shell:

image

Then enter the PowerShell code – screen shots below and code pasted below the images:

image

image

image

Code sample used in function:

# POST method: $req
$requestBody = Get-Content $req -Raw | ConvertFrom-Json
$projID = $requestBody.projID

# GET method: each querystring parameter is its own variable
if ($req_query_name) 
{
    $projID = $req_query_name 
}

#add SharePoint Online DLL - update the location if required
Import-Module "D:\home\site\wwwroot\ProjectSiteUserSyncHTTPTrigger\Microsoft.SharePoint.Client.dll"
Import-Module "D:\home\site\wwwroot\ProjectSiteUserSyncHTTPTrigger\Microsoft.SharePoint.Client.Runtime.dll"

#set the environment details
$PWAInstanceURL = "https://mod497254.sharepoint.com/sites/PWA2"
$username = "admin@MOD497254.onmicrosoft.com" 
$password = "password"
$securePass = ConvertTo-SecureString $password -AsPlainText -Force
#create the SharePoint list on the PWA site and add the correct columns based on the data required
$listname = "ProjectSnapShots"
$results1 = @()

#set the Odata URL with the correct project fields needed
$url = $PWAInstanceURL + "/_api/ProjectData/Projects()?`$Filter=ProjectId eq GUID'$projID'&`$Select=ProjectId,ProjectName,ProjectPercentCompleted"

#get all of the data from the OData URL
while ($url){
    [Microsoft.SharePoint.Client.SharePointOnlineCredentials]$spocreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePass);    
    $webrequest = [System.Net.WebRequest]::Create($url)
    $webrequest.Credentials = $spocreds
    $webrequest.Accept = "application/json;odata=verbose"
    $webrequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
    $response = $webrequest.GetResponse()
    $reader = New-Object System.IO.StreamReader $response.GetResponseStream()
    $data = $reader.ReadToEnd()
    $results = ConvertFrom-Json -InputObject $data
    $results1 += $results.d.results
        if ($results.d.__next){
        $url=$results.d.__next.ToString()
    }
    else {
        $url=$null
    }
}

#add data to snapshot list
#get PWA site client context
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($PWAInstanceURL) 
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePass) 
$ctx.Credentials = $credentials 
$ctx.ExecuteQuery()  
 
#get the target list 
$List = $ctx.Web.Lists.GetByTitle($listname) 
$ctx.Load($List) 
$ctx.ExecuteQuery() 

#for each project, create the list item - update the newitem with the correct list columns and project data
foreach ($projectrow in $results1) 
{ 
   $itemcreationInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation 
   $newitem = $List.AddItem($itemcreationInfo) 
   $newitem["Title"] = $projectrow.ProjectName
   $newitem["ProjectId"] = $projectrow.ProjectId
   $newitem["PercentCompleted"] = $projectrow.ProjectPercentCompleted
   $newitem.Update() 
   $ctx.ExecuteQuery() 
} 

The PowerShell code would need to be updated with your environment details: (PWAInstanceUrl, username, password and listname variables). Also the OData URL will need to be updated to include the project level fields that you want to snapshot.The target SharePoint list will also need to be set up in the PWA site collection for the project fields the script uses. This is the list I set up for this example:

image

SnapshotDate is set to Todays date so we don’t need to set that in the code.

The code is simple to follow but in summary the first part will get the projID from request body – we will pass in the ProjectID for the published project from the Flow / Logic App trigger. Then the SharePoint Online CSOM DLLs are imported in. Then the specific PWA environment details are set for the variables. The OData URL is then added to the url variable. Here notice we are filtering for the ProjectID and passing in the $projID variable we get from the request body. The Select part of the query will need to be updated for your project level fields. Next the code gets the data from the OData feed using the web request and adds the data into the results array. Once we have the data, we connect to the SharePoint list, in the example it is the ProjectSnapShots as set in the $listname variable. Lastly the new item is created in the list using the data from the results array.

Now the Azure Function is ready to be used. It can be tested using the Test option in the right hand panel, update the Request body:

image

Update it for a valid project ID. Then click Run above the function code:

image

The Logs window below will help you debug any errors etc.:

image

Then check the SharePoint list in the PWA site and the new item should have been created:

image

We now know the Azure Function is working as expected, now we need to call the Azure function when a project is published. All we need from the Azure Function is the URL to use, use the </>Get function URL button:

image

Select the correct Key, in this example I used the default function key. Copy the URL as it will be needed later.

To call the Azure Function when a project is published, the choice here for a no code option would be Microsoft Flow or Azure Logic App. For this I will use Microsoft Flow but the same steps (triggers , actions etc.) would be used in the Azure Logic App. Create a new Flow and search for Project Online:

image

Then select the Project Online – When a project is published trigger.

Enter the PWA URL:

image

Then click the ellipsis and set the connection for the PWA URL or create a new connection if needed:

image

Click + New step then Add an Action and search Http:

image

Select HTTP – HTTP:

image

Complete the HTTP action:

Method is POST, the Uri is the URL for the function that we copied earlier, Headers are not required. The Body is where we pass in the project ID from the published project trigger:

image

The Flow is now completed:

SNAGHTML55ecdca7

Now click Save flow.

In PWA, Publish a project or projects and see the snapshot data created on the configured snapshot list once the Flow has run:

Flow run:

image

Data added to the list for the project I published – in this example it was the Office 2016 rollout project:

image

This just shows a simple example and the some of the possibilities for extending the Project Online capability when making use of simple PowerShell scripts and other Microsoft 365 / Azure services for cloud / serverless solutions. Look out for more examples in the future.

Running #ProjectOnline #PowerShell in #Azure using #AzureFunctions #PPM #Cloud #Flow #LogicApp Part1

July 28, 2017 at 4:50 pm | Posted in Add-on, Administration, App, Configuration, Customisation, Fixes, Functionality, Information, PowerShell, Workflow | 4 Comments
Tags: , , , , , ,

Following on from my last post where I published an example solution starter PowerShell script for adding project team users to the Project Site, here I mentioned about running the script in an Azure Function and even running this sync from a Project Online event. The blog post can be seen below if you missed that:

https://pwmather.wordpress.com/2017/07/07/projectonline-project-user-sync-to-project-sites-ppm-o365-powershell-sharepoint/

Whilst I will use that example PowerShell script from my last blog post as an example, the concept will work for any PowerShell script.

I wont cover the details in setting up the Azure Function in part 1 as there is plenty of support out there for this – for this example I created an Http Trigger – PowerShell function.

image

I then uploaded the SharePoint DLLs and copied in the PowerShell script into the editor:

image

The project site user sync script didn’t work as is as I had to make some minor changes to get this to run from the Azure Function. This included change the way the SharePoint CSOM DLLs where loaded in. In the example script I used Add-Type to load the DLLs but in the Azure Function I had to switch this out to use Import-Module:

image

The next change I had to make was to comment out all of the feedback to the console, so all of the write-hosts. I also had to remove the functions within the script so that is was one block. After these changes I could execute the PowerShell script to add the project team members from my example project into the associated project site from the Azure Function. As this was an HTTP Trigger Azure Function, you can get the URL to the function and access that URL to execute the function.

This opens up lots of possibilities to easily execute this Azure Function from other applications that can make the HTTP call. For example you build easily execute this script once the project has been published either using a remote event receiver (RER) or a Microsoft Flow / Azure Logic App. The example script would need to be made generic and pass in a variable into the Azure Function for it to be a workable solution.

In part 2 of this blog post we will look at make a full event driven solution that is fired on project publish then executing the Azure Function and passing in a variable.

« Previous PageNext Page »

Blog at WordPress.com.
Entries and comments feeds.