Use 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 demonstrates 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 execute an Operation Set.

The following is 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 link status
  8. Initialize a variable for the number of tasks
  9. Initialize a variable for the project task ID
  10. Do until
  11. Set a project task
  12. Create a project task
  13. Create a resource assignment
  14. Decrement a variable
  15. Rename a project task
  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 Application Programming Interface (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. In 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. 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.

  1. Rename the step Create Project.
  2. In the Action Name field, select msdyn_CreateProjectV1.
  3. Under the msdyn_subject field, select Add dynamic content.
  4. On the Expression tab, in the function field, enter Project name - utcNow().
  5. 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 is 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 will be 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. 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 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. For the Project field, select msdyn_CreateProjectV1Response ProjectId in the Dynamic content dialog box.

Step 7: Initialize a variable for the link status

  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 linkstatus.
  5. In the Name field, enter linkstatus.
  6. In the Type field, select Integer.
  7. In the Value field, enter 192350000.

Step 8: 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 9: 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 project task ID.
  6. In the Type field, select String.
  7. For the Value field, enter guid() in the expression builder.

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 New step.
  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: Create a project task

Follow these steps to create a project task that has a unique ID that belongs to the current project and the project bucket that you created.

  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 Create Project Task.

  5. In the Action Name field, select msdyn_PssCreateV1.

  6. In the Entity 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_Project_Buckets')?['body/msdyn_projectbucketid']})",
        "msdyn_start": "@{addDays(utcNow(), 1)}",
        "msdyn_scheduledstart": "@{utcNow()}",
        "msdyn_scheduledend": "@{addDays(utcNow(), 5)}",
        "msdyn_LinkStatus": "192350000"
    }
    

    Here is 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 will be 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 will be 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 will be represented as "addDays(utcNow(), 1)".
    • msdyn_scheduledstart – The scheduled start date. For example, tomorrow will be 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 status. For example, enter "192350000".
  7. For the OperationSetId field, select msdyn_CreateOperationSetV1Response in the Dynamic content dialog box.

Step 13: Create a resource assignment

  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 Create Assignment.

  5. In the Action Name field, select msdyn_PssCreateV1.

  6. In the Entity 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']})"
    }
    
  7. For the OperationSetId field, select msdyn_CreateOperationSetV1Response in the Dynamic content dialog box.

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: Rename a project task

  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 Rename Project Task.

  5. In the Action Name field, select msdyn_PssUpdateV1.

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

    {
        "@@odata.type": "Microsoft.Dynamics.CRM.msdyn_projecttask",
        "msdyn_projecttaskid": "@{variables('msdyn_projecttaskid')}",
        "msdyn_subject": "ScheduleDemoTask1-UpdatedName"
    }
    
  7. For the OperationSetId field, select msdyn_CreateOperationSetV1Response 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 Dynamid content dialog box.

References