Use V2 Project schedule APIs with Power Automate

Applies To: Project Operations for resource/non-stocked based scenarios, Lite deployment - deal to proforma invoicing

This article describes a sample flow that shows how to create a complete project plan by using Microsoft Power Automate, how to create an Operation Set, and how to update an entity. The example shows how to create a project, project team member, Operation Sets, project tasks, and resource assignments. This article also explains how to update an entity and run an Operation Set.

The example in this article uses the PssCreateV2 API. For an example that uses the PssCreateV1 API, see Use V1 Project schedule APIs with Power Automate.

Here's a complete list of the steps that are documented in the sample flow in this article:

  1. Create a PowerApps trigger
  2. Create a project
  3. Initialize a variable for the team member
  4. Create a generic team member
  5. Create an Operation Set
  6. Create a project bucket
  7. Initialize a variable for the number of tasks
  8. Initialize a variable for the project task ID
  9. Initialize an array
  10. Do until
  11. Set a project task
  12. Add a task to the array
  13. Create a resource assignment
  14. Decrement a variable
  15. Add Tasks and Assignments to the Operation Set
  16. Run an Operation Set

Assumptions

This article assumes that you have a basic knowledge of the Dataverse platform, cloud flows, and the Project Schedule API. For more information, see the References section later in this article.

Create a flow

Select an environment

You can create the Power Automate flow in your environment.

  1. Go to https://flow.microsoft.com, and use your administrator credentials to sign in.
  2. In the upper-right corner, select Environments.
  3. In the list, select the environment where Dynamics 365 Project Operations is installed.

Create a solution

Follow these steps to create a solution-aware flow. By creating a solution-aware flow, you can more easily export the flow to use it later.

  1. On the navigation pane, select Solutions.
  2. On the Solutions page, select New solution.
  3. In the New solution dialog box, set the required fields, and then select Create.

Step 1: Create a PowerApps trigger

  1. On the Solutions page, select the solution that you created, and then select New.
  2. In the left pane, select Cloud flows > Automation > Cloud flow > Instant.
  3. In the Flow name field, enter Schedule API Demo Flow.
  4. In the Choose how to trigger this flow list, select Power Apps. When you create a Power Apps trigger, the logic is up to you as the author. For the example in this article, leave the input parameters blank for testing purposes.
  5. Select Create.

Step 2: Create a project

Follow these steps to create a sample project.

  1. In the flow that you created, select New step.

    Adding a new step.

  2. In the Choose an operation dialog box, in the search field, enter perform unbound action. Then, on the Actions tab, select the operation in the list of results.

    Selecting an operation.

  3. In the new step, select the ellipsis (), and then select Rename.

    Renaming a step.

  4. Rename the step Create Project.

  5. In the Action Name field, select msdyn_CreateProjectV1.

  6. Under the msdyn_subject field, select Add dynamic content.

  7. On the Expression tab, in the function field, enter concat('Project name - ',utcNow()).

  8. Select OK.

Step 3: Initialize a variable for the team member

  1. In the flow, select New step.
  2. In the Choose an operation dialog box, in the search field, enter initialize variable. Then, on the Actions tab, select the operation in the list of results.
  3. In the new step, select the ellipsis (), and then select Rename.
  4. Rename the step Init team member.
  5. In the Name field, enter TeamMemberAction.
  6. In the Type field, select String.
  7. In the Value field, enter msdyn_CreateTeamMemberV1.

Step 4: Create a generic team member

  1. In the flow, select New step.

  2. In the Choose an operation dialog box, in the search field, enter perform unbound action. Then, on the Actions tab, select the operation in the list of results.

  3. In the new step, select the ellipsis (), and then select Rename.

  4. Rename the step Create Team Member.

  5. For the Action Name field, select TeamMemberAction in the Dynamic content dialog box.

  6. In the Action Parameters field, enter the following parameter information.

    {
        "TeamMember": {
            "@@odata.type": "Microsoft.Dynamics.CRM.msdyn_projectteam",
            "msdyn_projectteamid": "@{guid()}",
            "msdyn_project@odata.bind": "/msdyn_projects(@{outputs('Create_Project')?['body/ProjectId']})",
            "msdyn_name": "ScheduleAPIDemoTM1"
        }
    } 
    

    Here's an explanation of the parameters:

    • @@odata.type – The entity name. For example, enter "Microsoft.Dynamics.CRM.msdyn_projectteam".
    • msdyn_projectteamid – The primary key of the project team ID. The value is a globally unique identifier (GUID) expression. The ID is generated from the Expression tab.
    • msdyn_project@odata.bind – The project ID of the owning project. The value is dynamic content that comes from the response of the "Create Project" step. Make sure that you enter the full path and add dynamic content between the parentheses. Quotation marks are required. For example, enter "/msdyn_projects(ADD DYNAMIC CONTENT)".
    • msdyn_name – The name of the team member. For example, enter "ScheduleAPIDemoTM1".

Step 5: Create an Operation Set

  1. In the flow, select New step.
  2. In the Choose an operation dialog box, in the search field, enter perform unbound action. Then, on the Actions tab, select the operation in the list of results.
  3. In the new step, select the ellipsis (), and then select Rename.
  4. Rename the step Create Operation Set.
  5. In the Action Name field, select the msdyn_CreateOperationSetV1 Dataverse custom action.
  6. In the Description field, enter ScheduleAPIDemoOperationSet.
  7. For the Project field, select msdyn_CreateProjectV1Response ProjectId in the Dynamic content dialog box.

Step 6: Create a project bucket

  1. In the flow, select New step.
  2. In the Choose an operation dialog box, in the search field, enter add new row. Then, on the Actions tab, select the operation in the list of results.
  3. In the new step, select the ellipsis (), and then select Rename.
  4. Rename the step Create Bucket.
  5. In the Table Name field, select Project Buckets.
  6. In the Name field, enter ScheduleAPIDemoBucket1.
  7. In the Project field, enter /msdyn_projects(.
  8. In the Dynamic content dialog box, select msdyn_CreateProjectV1Response ProjectId.
  9. In the Project field, enter ).

Step 7: Initialize a variable for the number of tasks

  1. In the flow, select New step.
  2. In the Choose an operation dialog box, in the search field, enter initialize variable. Then, on the Actions tab, select the operation in the list of results.
  3. In the new step, select the ellipsis (), and then select Rename.
  4. Rename the step Init Number of tasks.
  5. In the Name field, enter number of tasks.
  6. In the Type field, select Integer.
  7. In the Value field, enter 5.

Step 8: Initialize a variable for the project task ID

  1. In the flow, select New step.
  2. In the Choose an operation dialog box, in the search field, enter initialize variable. Then, on the Actions tab, select the operation in the list of results.
  3. In the new step, select the ellipsis (), and then select Rename.
  4. Rename the step Init ProjectTaskID.
  5. In the Name field, enter msdyn_projecttaskid.
  6. In the Type field, select String.
  7. For the Value field, enter guid() in the expression builder.

Step 9: Initialize an array

  1. In the flow, select New step.
  2. In the Choose an operation dialog box, in the search field, enter initialize variable. Then, on the Actions tab, select the operation in the list of results.
  3. In the new step, select the ellipsis (), and then select Rename.
  4. Rename the step Init Array.
  5. In the Name field, enter Tasks and Assignments.
  6. In the Type field, select Array.

Step 10: Do until

  1. In the flow, select New step.
  2. In the Choose an operation dialog box, in the search field, enter do until. Then, on the Actions tab, select the operation in the list of results.
  3. Set the first value in the conditional statement to the number of tasks variable from the Dynamic content dialog box.
  4. Set the condition to less than equal to.
  5. Set the second value in the conditional statement to 0.

Step 11: Set a project task

  1. In the flow, select Add an action.
  2. In the Choose an operation dialog box, in the search field, enter set variable. Then, on the Actions tab, select the operation in the list of results.
  3. In the new step, select the ellipsis (), and then select Rename.
  4. Rename the step Set Project Task.
  5. In the Name field, select msdyn_projecttaskid.
  6. For the Value field, enter guid() in the expression builder.

Step 12: Add a task to the array

  1. In the flow, select New step.

  2. In the Choose an operation dialog box, in the search field, enter Append to array.

  3. In the step, select the ellipsis (), and then select Rename.

  4. Rename the step Add Task to Array.

  5. In the Name field, select Tasks and Assignments.

  6. In the Value field, enter the following parameter information.

    {
        "@@odata.type": "Microsoft.Dynamics.CRM.msdyn_projecttask",
        "msdyn_projecttaskid": "@{variables('msdyn_projecttaskid')}",
        "msdyn_project@odata.bind": "/msdyn_projects(@{outputs('Create_Project')?['body/ProjectId']})",
        "msdyn_subject": "ScheduleAPIDemoTask1",
        "msdyn_projectbucket@odata.bind": "/msdyn_projectbuckets(@{outputs('Create_Bucket')?['body/msdyn_projectbucketid']})",
        "msdyn_start": "@{addDays(utcNow(), 1)}",
        "msdyn_scheduledstart": "@{utcNow()}",
        "msdyn_scheduledend": "@{addDays(utcNow(), 5)}",
        "msdyn_LinkStatus": "192350000"
    }
    

    Here's an explanation of the parameters:

    • @@odata.type – The entity name. For example, enter "Microsoft.Dynamics.CRM.msdyn_projecttask".
    • msdyn_projecttaskid – The unique ID of the task. The value should be set to a dynamic variable from msdyn_projecttaskid.
    • msdyn_project@odata.bind – The project ID of the owning project. The value is dynamic content that comes from the response of the "Create Project" step. Make sure that you enter the full path and add dynamic content between the parentheses. Quotation marks are required. For example, enter "/msdyn_projects(ADD DYNAMIC CONTENT)".
    • msdyn_subject – Any task name.
    • msdyn_projectbucket@odata.bind – The project bucket that contains the tasks. The value is dynamic content that comes from the response of the "Create Bucket" step. Make sure that you enter the full path and add dynamic content between the parentheses. Quotation marks are required. For example, enter "/msdyn_projectbuckets(ADD DYNAMIC CONTENT)".
    • msdyn_start – Dynamic content for the start date. For example, tomorrow is represented as "addDays(utcNow(), 1)".
    • msdyn_scheduledstart – The scheduled start date. For example, tomorrow is represented as "addDays(utcNow(), 1)".
    • msdyn_scheduleend – The scheduled end date. Select a date in the future. For example, specify "addDays(utcNow(), 5)".
    • msdyn_LinkStatus – The link to the billing setup. For example, enter "192350000" if there's no link to the billing setup or "192350001" if the billing setup is linked.

Step 13: Create a resource assignment

  1. In the flow, select Add an action.

  2. In the Choose an operation dialog box, in the search field, enter Append to Array.

  3. In the step, select the ellipsis (), and then select Rename.

  4. Rename the step Add Assignment to Array.

  5. In the Name field, select Tasks and Assignments.

  6. In the Value field, enter the following parameter information.

    {
        "@@odata.type": "Microsoft.Dynamics.CRM.msdyn_resourceassignment",
        "msdyn_resourceassignmentid": "@{guid()}",
        "msdyn_name": "ScheduleAPIDemoAssign1",
        "msdyn_taskid@odata.bind": "/msdyn_projecttasks(@{variables('msdyn_projecttaskid')})",
        "msdyn_projectteamid@odata.bind": "/msdyn_projectteams(@{outputs('Create_Team_Member')?['body/TeamMemberId']})",
        "msdyn_projectid@odata.bind": "/msdyn_projects(@{outputs('Create_Project')?['body/ProjectId']})"
    }
    

Step 14: Decrement a variable

  1. In the flow, select New step.
  2. In the Choose an operation dialog box, in the search field, enter decrement variable. Then, on the Actions tab, select the operation in the list of results.
  3. In the Name field, select number of tasks.
  4. In the Value field, enter 1.

Step 15: Add Tasks and Assignments to the Operation Set

  1. In the flow, select New step.
  2. In the Choose an operation dialog box, in the search field, enter perform unbound action. Then, on the Actions tab, select the operation in the list of results.
  3. In the step, select the ellipsis (), and then select Rename.
  4. Rename the step Add Tasks and Assignments to Operation Set.
  5. In the Action Name field, select msdyn_PssCreateV2.
  6. For the OperationSetId field, select msdyn_CreateOperationSetV1Response OperationSetId in the Dynamic content dialog box.
  7. In the EntityCollection field, select Switch Input to Entire Array.
  8. For the EntityCollection field, select Tasks and Assignments in the Dynamic content dialog box.

Step 16: Run an Operation Set

  1. In the flow, select New step.
  2. In the Choose an operation dialog box, in the search field, enter perform unbound action. Then, on the Actions tab, select the operation in the list of results.
  3. In the step, select the ellipsis (), and then select Rename.
  4. Rename the step Execute Operation Set.
  5. In the Action Name field, select msdyn_ExecuteOperationSetV1.
  6. For the OperationSetId field, select msdyn_CreateOperationSetV1Response OperationSetId in the Dynamic content dialog box.

References