Use V1 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 run an Operation Set.

The example in this article uses the PssCreateV1 API. For an example that uses the PssCreateV2 API, see V2 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 Power Apps 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. Initialize a variable for the Project Bucket ID
  7. Create a project bucket
  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 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 Power Apps 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. In the Project field, from the Dynamic content dialog box, select msdyn_CreateProjectV1Response ProjectId.

Step 6: Initialize variable for Project Bucket 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 Project Bucket ID.
  5. In the Name field, enter project bucket id.
  6. In the Type field, select String.
  7. In the Value field, enter @{guid()}.

Step 7: Create a project bucket

  1. In the flow, select Add an action.

  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 Bucket.

    1. In the Action Name field, select msdyn_PssCreateV1.
  5. In the Entity field, enter the following parameter information.

    {
        "@@odata.type": "Microsoft.Dynamics.CRM.msdyn_projectbucket",
        "msdyn_projectbucketid": "@{variables('project bucket id')}",
        "msdyn_name": "ScheduleAPIDemoBucket1",
        "msdyn_project@odata.bind": "/msdyn_projects(@{outputs('Create_Project')?['body/ProjectId']})",
    }
    

    Here's an explanation of the parameters:

    • @@odata.type – The entity name. For example, enter "Microsoft.Dynamics.CRM.msdyn_projectbucket".
    • msdyn_projectbucketid – The unique ID of the project bucket. The value should be set from the dynamic variable from step 6.
    • 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 project bucket name.
  6. For the OperationSetId field, select msdyn_CreateOperationSetV1Response OperationSetId in the Dynamic content dialog box.

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 msdyn_projecttaskid.
  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 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: 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(@{variables('project bucket id')})",
        "msdyn_start": "@{addDays(utcNow(), 1)}",
        "msdyn_scheduledstart": "@{utcNow()}",
        "msdyn_scheduledend": "@{addDays(utcNow(), 5)}"
    }
    

    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 the same as used to set the msdyn_projectbucketid on 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 status. For example, enter "192350000".
  7. For the OperationSetId field, select msdyn_CreateOperationSetV1Response OperationSetId in the Dynamic content dialog box.

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 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 OperationSetId 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 OperationSetId 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