Project Online – Setting up default SharePoint field values with Microsoft Flow and Project/SharePoint Rest API

In this post, it’ll be shown how to set the default Risks list items title based on Project Name in project online, with the help of Microsoft Flow, Project Online Rest API and SharePoint Online Rest API.

The “Send an HTTP request to SharePoint” allows us to overcome lots of the out-of-the-box SharePoint/Project Online Flow connectors limitations, by accessing various different endpoints.

Basically, we can do almost everything we would do using Javascript or C# in conjunction with the Project Online and SharePoint Rest APIs.

Our trigger, in this case, will be “When a project is created”. Specify your PWA site address.

Action001

Then, for the next action we are going to use the action “Send an HTTP request to SharePoint” so that we can get information just from that recently created project (otherwise we would need to loop through all the projects using the “List all Projects” action.

We are going to send a Get request to all the projects endpoint, filtering by project ID with the following expression:

_api/ProjectData/Projects(guid'<Your project Id from the trigger here>’)

Action002

Then with the results of this request, we are going to do a Patch request on the Risks list of the Project Workspace SharePoint Site for that project, so that we update its default value, using the list/fields endpoint calling the Title field in this case:

_api/web/lists/getbytitle(‘Risks’)/Fields/GetByTitle(‘Title’)

To get the proper site Url, we need to use custom site Url, with dynamic content/expression, so that we extract the information from the returned JSON values:

The expression used in this case will be:

body(‘Send_an_HTTP_request_to_SharePoint’)[‘d’][‘ProjectWorkspaceInternalUrl’]

Note that the ‘Send_an_HTTP_request_to_SharePoint’ is the title of the action we created previously, separated by underscores “_”.

If you rename your action, this title will be different.

Then in the body of the request, we will use the following JSON content:

{  ‘Title’: ‘Title’, ‘DefaultValue’: ‘<EXPRESSION> Risk’ }

Action003

Where in the expression part, you’ll need to input an expression from dynamic content with the following expression, so you can access the Project Name from the returned JSON result (you can watch the results when flow runs to ‘debug’ the JSON properties returned and check for other properties, in order to build your own expression if preferred):

body(‘Send_an_HTTP_request_to_SharePoint’)[‘d’][‘ProjectName’]

Capture2

Now if you create a new Project, wait for the flow to be executed, an all the new risks will have the proper default title configured:

Capture4

The possibilities with the action “Send an HTTP request to SharePoint” are infinite!

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *