#ProjectOnline #PowerApps example #Office365 #PPM #PMOT #Apps #MSProject #SharePoint Part2

February 24, 2018 at 10:17 pm | Posted in Add-on, Administration, App, Configuration, Customisation, Functionality, Information, Mobile | Leave a comment
Tags: , , , , ,

In part 2 of this series we look at continuing with the example PowerApp for Project Online for project details and project navigation. For those of you that missed part 1, a link to the post can be found below:

https://pwmather.wordpress.com/2018/02/21/projectonline-powerapps-example-office365-ppm-pmot-apps-msproject-part1/

In part 2 we will update the detail screen to display the data we want and include links to PWA for the associated project. If you are following, open the app you started in part 1:

image

Using the tree view on the left, click DetailScreen1 to load the detail screen or click the chevron next to a project from the browse screen:

SNAGHTMLad72abf

Firstly I updated the screen label to “Project Details” and deleted the delete and edit icons:

SNAGHTMLadf40c1

Next two buttons were added to the top bar, one for the Site and one for the Tasks. The Site button will launch DataCardValue8 which in my case is the Project Site URL as seen below:

SNAGHTMLaf5ceae

The Tasks button will launch the Project Schedule PDP but concatenating the PWA URL for the schedule PDP (or whatever PDP you want to link to) then using the ProjectID, in my case DataCardValue2, from the detail screen for the projuid URL parameter:

SNAGHTMLafa7b75

The buttons were added to the screen using the insert menu:

image

As you can see, there are lots of options on the insert ribbon! Other quick links could easily be added such as Issues, Risks, New Risk etc. That is it for the detail view, we have some project details and two buttons that link out to PWA for the associated project:

SNAGHTMLb051b8d

Just for fun I also added a new screen in for a chart. I inserted a bar chart and created a project count by progress chart:

image

For the Items, I entered the following formula to count the number of projects Completed, Not Starter or In Progress:

image

The formula is below for my data, ProjectData is the name of my SharePoint list and Progress is the column on my SharePoint list that contains the % complete value for each project:

Table(
    {Column: "Completed", Value: CountIf(ProjectData, Progress = 100)
    },
    {Column: "Not Started", Value: CountIf(ProjectData, Progress = 0)
    },
    {Column: "In Progress", Value: CountIf(ProjectData, Progress <> 0 && Progress <> 100)
    }
)

Then set the item colours:

image

I then added the back arrow to navigate back to the main browse screen:

image

The final change was to add an icon to the main browse screen that enabled navigation to the chart screen:

image

To preview your app in PowerApps, press F5:

Main screen: list of projects with search and sort using project name, link for each project to project detail screen, access to chart screen, refresh the data and link to create a new project in Project Online

image

Details screen: project details with button links to the project site or schedule PDP in Project Online PWA and a back button to the main screen

SNAGHTMLb7913d8

Chart screen: bar chart display project count by progress for Completed, Not Started and In Progress with a back button to the main screen

image

Once you are happy with your app you can share it to your organisation. Before you do, access the App Settings view and give it a name, set the icon and description:

image 

Then click Save and save it to your organisations PowerApps environment then share the app:

SNAGHTMLb8e0f8c

For details on Saving, publishing and sharing your apps see the links here: https://docs.microsoft.com/en-us/powerapps/save-publish-app & https://docs.microsoft.com/en-us/powerapps/share-app Users can then access your app using the browser, PowerApps Studio or the PowerApps mobile app!

Hopefully that has given you enough to get started or given you some ideas for Project Online PowerApps. There are so many features to PowerApps, they are very powerful! For getting started guides on PowerApps start here: https://docs.microsoft.com/en-us/powerapps/getting-started

Have fun!

Advertisements

#ProjectOnline #PowerApps example #Office365 #PPM #PMOT #Apps #MSProject Part1

February 21, 2018 at 11:47 pm | Posted in Add-on, Administration, App, Configuration, Customisation, Functionality, Information, Mobile | 1 Comment
Tags: , , , ,

PowerApps aren’t a new feature in Office 365 but not one that I have blogged about before, mainly due to the lack of native support for Project Online, but I have created apps before using PowerApps  – it’s an awesome application! PowerApps provide a great way for users to create powerful business apps without writing code. You can use the same connectors that have use for Flow etc. so there is great support for SharePoint Online but no so much for Project Online. To get around this, the easiest approach is to have your Project Online data in a SharePoint list, I have covered a few examples with code samples before:

https://pwmather.wordpress.com/2018/01/27/projectonline-project-level-html-fields-to-a-sharepoint-list-powershell-ppm-office365/

https://pwmather.wordpress.com/2016/08/26/projectonline-data-capture-snapshot-capability-with-powershell-sharepoint-office365-ppm-bi/

In this series of posts, we will create a simple navigation type app for Project Online using PowerApps. In part 1 we look at getting started and creating / updating the browse / home screen. To do this we will need the Project Online data in a SharePoint list using a similar process as the examples above. This post assumes you already have your Project Online data available in a SharePoint Online list and a process to keep this updated as your Project Online changes, similar to the list below:

SNAGHTML6eb4d2

Access PowerApps from the Office 365 app launcher:

image

This will launch PowerApps:

image

If you haven’t used SharePoint Online in Flow or PowerApps before, firstly you will need to click Connections > New Connections > Type SharePoint in the Search bar and add the SharePoint connection:

image

Once you have the connection you can create the app. To create the PowerApp you can either use the web based PowerApps Studio that can be accessed on the Apps page:

image

Or there is an App available in the Microsoft Store:

image

For the purpose of this blog post I will be using the Windows 10 App but the steps are the same.

Once the App launches, you can Open existing apps:

image

Or create a new one, click the New button:

image

From here you can create an app starting with your data, start from a blank canvas or start from a template. The templates options will present you with template previews to select from:

image

For the purpose of the this blog post and to keep the blog post shorter, we will start with our SharePoint data, if this is your first PowerApp this might be the best option to start with until you’re familiar with PowerApps:

image

Type the URL of the site that contains the list:

SNAGHTML787fc7

Press Go then select the correct list and press Connect, in this example it is ProjectData:

image

PowerApps will then build a working app for you based on the data in your SharePoint list:

image

Once finished, home / browse screen is displayed:

image

Clicking the chevron for a project loads the detail screen:

image

That might be good enough for some scenarios – pretty awesome given it was a click of a button! As mentioned, we will look to make a navigation type app that displays some high level project information so we will make some minor tweaks to the base app PowerApps kindly created for us.

Clicking on different areas on the canvas will enable different settings or you can click the elements using the left hand tree view. The first item we will change is the ProjectData label which by default takes the source list name. This property is the LblAppName1:

image

Moving down the screen, we want to change the search feature so that the search box and sorting work on the Project Name. To do this, select BrowseGallery1 from the left hand tree view, then click Advanced, finally update the Data items. Replace ComplianceAssetId with Title as seen below in two places:

image

The search box and sort icon will now work on the Project Name – in our case this is Title on the source SharePoint list.

Next up we want to see Project Name and Project Owner on the project summary section. Using the left hand tree view, click Title1 then access the Advanced menu. In the DATA section under the Text property, update this to “ThisItem.Title”:

image

Notice the Project Name now appears. Repeat for Subtitle1 and select a different project property or multiple properties, I will set the Project Owner and % complete:

image

I will also change the Body1 property to display the Project Start and Finish Dates:

image

The final change for the browse screen in part 1 of this blog post is to change the IconNewItem1, this is the + symbol in the top right corner. In the default app, this will load the edit screen to create a new list item, for this example we will point this to load the create project page in Project Online. Select the IconNewItem1 from the left hand tree view, replace the OnSelect “NewForm(EditForm1;Navigate(EditScreen1, None) with Launch(https://PWASiteURL/_layouts/15/PWA/Wizards/CreateProject.aspx) and update the tooltip as seen below:

SNAGHTMLb94801

The browse screen should look something like this now:

image

With the ability to search and sort on Project Name:

image

Worth noting is that this project data will not be security trimmed etc.

We have barely touched the surface of PowerApps but that is it for Part 1. In Part 2 we look at updating the detail view and adding in links to navigate to the project in PWA.

#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 | Leave a comment
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!

#ProjectOnline Project level #HTML fields to a #SharePoint list #PowerShell #PPM #Office365

January 27, 2018 at 10:01 pm | Posted in Add-on, Administration, Configuration, Customisation, Functionality, Information, PowerShell, Reporting | 1 Comment
Tags: , , , ,

Following on from my previous mini series of posts for including the HTML formatting in Project Online Power BI reports, this post is a supporting blog post for the PowerShell script I used in the 3rd post. For those that missed that mini series of posts, the links are below:

Part 1: https://pwmather.wordpress.com/2018/01/01/projectonline-powerbi-report-include-html-formatting-ppm-pmot-powerquery-odata-rest-part-1/

Part 2: https://pwmather.wordpress.com/2018/01/03/projectonline-powerbi-report-include-html-formatting-ppm-pmot-powerquery-odata-rest-part-2/

Part 3: https://pwmather.wordpress.com/2018/01/16/projectonline-powerbi-report-include-html-formatting-ppm-pmot-powerquery-odata-rest-part-3/

This blog post is the supporting blog post for the script sample published to the Microsoft Script Gallery: https://gallery.technet.microsoft.com/Online-Level-HTML-fields-5dc31a38

This PowerShell script will use the Project Reporting OData API to get all of the published projects in the Project Online PWA Site Collection, then for each project it will get the project level multiple lines of text fields that include the HTML from the REST API and then create a list item on the specified SharePoint list. The user setting up the script will need to make some changes to the script , this is covered in the blog post.

The account used will need access to the OData API in PWA, at least full read access to all projects and contribute access to the target SharePoint list. The SharePoint list will also need to be created beforehand with the required columns.

To get the script to work you will need to reference the DLL as seen in the image below:

image

This can be installed from the SharePoint Online Client components / management shell. I used the dll from the SharePoint Online Management Shell in this example.

Firstly decide what project level multiple lines of text fields you want to include, this will determine the list column requirements. Then create the SharePoint list in the PWA site collection with the required columns, for this example I created a list called ProjectMutliLineFields with the columns below:

image

I used the default Title field for the Project Name, ProjectId for the Project GUID then I created four multiple lines of text columns for my example project multiple lines of text fields. Set up the list and columns as required then update line 45 in the sample script to change the select query to include the correct project fields you need:

$url = $PWAInstanceURL + "/_api/ProjectServer/Projects(guid'$projectID')/IncludeCustomFields?`$Select=Name,Id,Custom_x005f_4d0daaaba6ade21193f900155d153dd4,Custom_x005f_3f9c814ca2ade21193f900155d153dd4,Custom_x005f_a801708ea5ade21193f900155d153dd4,Custom_x005f_70534c6aa2ade21193f900155d153dd4"

You will at least need to change all of the custom field GUIDs to be the correct GUIDs for your project fields. If you are unsure on how to get the correct custom field GUIDs, see post 2 in the HTML reporting series.

You will then need to update the list item creation part of the sample script to map to the correct SharePoint column names you created and the project fields:

image

Also ensure the variables have been updated correctly, placeholder values seen below:

image

Save and run the PowerShell script (fully test on a non-production PWA site collection before Production) to ensure the data is captured correctly in the target SharePoint list. This script could be run manually on demand or on schedule using a scheduled task if running on a server or a scheduled Azure Function or other methods.

Once the script is run you will see the data in the SharePoint list (data from our sales demo instance):

image

Whilst the purpose of this script was to enable us to get the data easily in Power BI in a such a way that supported refreshing in the Power BI Service, as you can see in the screen shot above, this list includes all of the HTML formatting in a central view – something you can’t get in a PWA Project Center view! Do keep in mind that this SharePoint list would not be security trimmed like a Project Center view though, so you might want to restrict access to the SharePoint list depending on your data / security policies for your PPM data.

Running the script multiple times will create multiple items for each project so you might want to set up grouping on the view or update the script to modify the SharePoint list item with the updated data so that you only have one list item per project.

The script is provided "As is" with no warranties etc.

#ProjectOnline #PPM #PowerBI Report Pack v2 #BI #Reporting #PowerQuery #DAX #Office365

October 31, 2017 at 12:39 pm | Posted in Add-on, Administration, Customisation, Functionality, Information, Reporting | 2 Comments
Tags: , , , ,

Back in January this year I published my first Power BI report pack for Project Online, the post can be found here: https://pwmather.wordpress.com/2017/01/03/projectonline-ppm-powerbi-report-pack-bi-reporting-powerquery-dax-office365/ I have now published the second version of my report pack for Project Online. This version can be download from the link below:

https://gallery.technet.microsoft.com/Online-Power-BI-Report-abcb3c3b

This report pack consists of 8 reports for Project Online, these reports can be seen below:

Portfolio Report page:

image

Issues Report page:

image

Risks Report page:

image

Project Report page:

image

Resource Demand Report page:

image

Resource Report page:

image

Timesheet Summary Report page:

image

Timesheet Detail Report page:

image

These reports only use default intrinsic fields so it should work for all Project Online deployments.

Once downloaded, the report pack data sources will need to be updated to point to your target Project Online PWA instance. 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 PWMatherProjectOnlinePowerBIReportPackv2.pbit template file in Power BI Desktop and follow the steps below to point the data sources to your Project Online PWA instance:

 

  • In the parameter window that opens, enter the full Project Online PWA URL
  • Click Load
  • The data will now start to load and you will be prompted to connect
  • On the OData feed window, click Organizational account and click Sign in and enter credentials as required
  • Click Connect
  • On the Privacy levels window set the privacy as required
  • Click Save
  • The data will load – this may take a few minutes depending on the dataset size in Project Online
  • Access the Project Report page and select a project from the project filter
  • Save the report

This file can either be emailed around to colleagues with details on how to update the credentials to their own or what would be better is to publish the report to your Power BI workspace can create an organisational content pack that others can add to their Power BI workspace. If the Power BI organisational content pack is the chosen option, you might want to create a Dashboard first. See a previous blog post on this: https://pwmather.wordpress.com/2017/02/10/projectonline-ppm-powerbi-report-pack-publish-bi-reporting-powerquery-dax-office365/

Enjoy, I hope you like it Smile

#ProjectOnline #PowerBI content pack 2 available #BI #Office365 #PPM update

October 19, 2017 at 11:56 am | Posted in Add-on, Administration, Customisation, Functionality, Information, Reporting | 1 Comment
Tags: , , , ,

Following on from my previous blog post regarding the updated Project Online Power BI content pack from Microsoft –  see below if you missed it:

https://pwmather.wordpress.com/2017/09/26/projectonline-powerbi-content-pack-2-available-bi-office365-ppm/

That was shortly removed from the Power BI service and hasn’t been updated there yet but the template file has since been made available to download from GitHub:

https://github.com/OfficeDev/Project-Power-BI-Content-Packs

You can now have the default reports provided here and extend to your own requirements for example a quick change would be to change the currency symbol used if you are not using US dollars:

image

Another change you might want to do, is make this report pack support non-English PWA site collections. This can be done by editing all of the queries in the Query Editor, use the Advanced Editor and update the code: OData.Feed(#”PWA Site URL” & “/_api/ProjectData”), to OData.Feed(#”PWA Site URL” & “/_api/ProjectData/[en-US]“), This will ensure all of the properties exist and the reports work.

Make the changes as required then publish to your own organisation.

#SharePoint item count from all lists on all sub webs in SharePoint / #ProjectOnline #PPM #PowerShell

September 28, 2017 at 11:29 am | Posted in Add-on, Administration, Customisation, Functionality, Information, PowerShell, Reporting | Comments Off on #SharePoint item count from all lists on all sub webs in SharePoint / #ProjectOnline #PPM #PowerShell
Tags: , , , ,

This is a supporting blog post for an example PowerShell script I quickly wrote for Microsoft’s Office 365 SharePoint Online. It was created after a query was posted on the Project Online TechNet forums asking how to easily check what sub sites were being used in PWA.

The code sample can be downloaded from here: https://gallery.technet.microsoft.com/Get-item-count-from-all-026a6db2

To get the script to work, there will need to be some environment variables set and a DLL available, these are detailed below.

Update the environment details:

image

Add the SharePoint Online / PWA URL, username and password for an account that is a site collection admin on the target site collection.

To get the script to work you will need to reference the DLL as seen in the image below:

image

This can be installed from the SharePoint Online Client components / management shell. I used the dll from the SharePoint Online Management Shell in this example.

Below you can see the output from the PowerShell ISE when running against my test SharePoint / Project Online site collection:

SNAGHTML9ae65556

There are probably easier ways to view this information but I thought I would just try with a simple PowerShell script.

#ProjectOnline #PowerBI content pack 2 available #BI #Office365 #PPM

September 26, 2017 at 4:14 pm | Posted in Add-on, Administration, Customisation, Functionality, Information, Reporting | 5 Comments
Tags: , , , ,

2 years ago Microsoft released the first Project Online Power BI Content Pack, this week they have released another updated Project Online content pack! This is available now. For details on how to get the content pack see my original post below:

https://pwmather.wordpress.com/2015/11/18/projectonline-powerbi-content-pack-available-bi-office365-ppm/

The steps are the same to get the new Project Online Content pack. This is version 2.3 as seen below:

image

Once the data is imported access the Report and Dashboard from the Power BI App > My Workspace navigation. I have set this up against our sales demo instance for Project Online. There are default reports for:

Portfolio Dashboard:image

Portfolio Timeline:image

Portfolio Costs:image

Portfolio Milestones:image

Portfolio Risks:image

Portfolio Issues:image

Resource Availability:image

Resource Overview:image

Resource Assignments:image

Resource Details – you will need to select a resource from the Resource Name filter:image

Resource Demand Forecast:image

Project Status – you will need to select a project from the Project filter:image

Project Risks & Issues – you will need to select a resource from the Project filter:image

Report Dashboard:image

Together with this content pack and the example report pack I built earlier this year, there are plenty of examples of reports to make Project Online reporting a simple task! A link to my report pack can be seen below:

https://pwmather.wordpress.com/2017/01/03/projectonline-ppm-powerbi-report-pack-bi-reporting-powerquery-dax-office365/

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.

Next Page »

Blog at WordPress.com.
Entries and comments feeds.