Skip to main content

Notifications

Project Operations forum
Answered

How do we assign a person into a Project Task using Schedule API?

Posted on by 6
The requirement is to create a Project Task using Power Automate and assign a person into it. Then it needs to display in the Assigned to column in Project for the Web UI.
 
 
As per the documentation, we can create Team and assign it into a task. But not sure how we can map a person to this team or directly assign a person instead of Team.
  • SS-27051606-0 Profile Picture
    SS-27051606-0 2 on at
    How do we assign a person into a Project Task using Schedule API?
    Hey Guys,
    i tried to follow the explantion from anna.zurawska.

    I have the following issue:
    1. When adding a User / Mail Addresse to variable EMAIL, who is not member of the Team, the assignment is working perfectly.
    2. When adding a User / Mail Addresse to variable EMAIL, who is member of the Team, the assignment is not working. I get the following error message and the flow fails.

    {
      "error": {
        "code": "0x80040265",
        "message": "A duplicate resource was found. The user is already a member of the team."
      }
    }

    2.1 When i´m configuring the run after step on Create Task to "Continue on error", the flow keeps running till  "Create Resource Assigment" and it fails again with the error message:

    {
      "error": {
        "code": "0x80040265",
        "message": "ScheduleAPI-AV-0006:262de80d-441c-ef11-840a-000d3ab0ce2e: The entity “msdyn_projectteam” with the ID “XXXXXXX-59a7f6f5b05”, which is referenced in the entity “msdyn_resourceassignment” with the ID “XXXXXXX-3bf449fd”, does not exist."
      }
    }
     
    My test-flow:
     
     
     
     

    Does anyone have any idea how to solve this issue?
  • Verified answer
    anna.zurawska Profile Picture
    anna.zurawska 9 on at
    How do we assign a person into a Project Task using Schedule API?
    Hey Guys,

    I managed to assign a person to 'Assign To' column of the Task in P4TW with Power Automate and Schedule API.

    In my scenario I assume that Project, Project Bucket and Bookable Resource already exist and I fetch Bookable Resource record based on email address. I'm creating a new task and then assigning a bookable resource.

    The steps are the following:

    1:  Prepare the data:
    Initialize variables
    some of variables such as TaskID and TeamID have to be initialized with guid() expression; Other variables in my scenario are hardcoded.

    1.1. Get Project Bucket

    1.2. Get Project Team

    1.3. Get Bookable Resource
    <fetch>
      <entity name="bookableresource">
        <attribute name="userid" />
        <attribute name="bookableresourceid" />
        <link-entity name="systemuser" from="systemuserid" to="userid">
          <filter>
            <condition attribute="internalemailaddress" operator="eq" value="@{variables('UserEmail')}" />
          </filter>
        </link-entity>
      </entity>
    </fetch>
    2. Create Operation Set
    Use Perform an unboand action
     
    3. Prepare And Execute Operation Set
    Create Team Member
    Use action msdyn_CreateTeamMemberV1 from dataverse (perform an unboand action)
    {
      "TeamMember": {
        "@{outputs('OData')}": "Microsoft.Dynamics.CRM.msdyn_projectteam",
        "msdyn_projectteamid": "@{variables('TeamID')}",
        "msdyn_project@odata.bind": "/msdyn_projects(@{variables('ProjectID')})",
        "msdyn_bookableresourceid@odata.bind": "/bookableresources(@{outputs('Get_ResourceID')})"
      }
    }
    Create a Task
    Perform an unboand action
    {
      "@{outputs('OData')}": "Microsoft.Dynamics.CRM.msdyn_projecttask",
      "msdyn_projecttaskid": "@{variables('TaskID')}",
      "msdyn_project@odata.bind": "/msdyn_projects(@{variables('ProjectID')})",
      "msdyn_description": "Test",
      "msdyn_subject": "Test resource Assigmnent",
      "msdyn_projectbucket@odata.bind": "/msdyn_projectbuckets(@{outputs('Get_Bucket_ID')})",
      "msdyn_start": "@{addDays(utcNow(), 1)}",
      "msdyn_scheduledstart": "@{utcNow()}",
      "msdyn_scheduledend": "@{addDays(utcNow(), 5)}"
    }
    Create Resource Assignment
    Perform an unboand action
    {
      "msdyn_name": "Test",
      "msdyn_projectid@odata.bind": "/msdyn_projects(@{variables('ProjectID')})",
      "msdyn_projectteamid@odata.bind": "/msdyn_projectteams(@{variables('TeamID')})",
      "msdyn_taskid@odata.bind": "/msdyn_projecttasks(@{variables('TaskID')})",
      "@{outputs('OData')}": "Microsoft.Dynamics.CRM.msdyn_resourceassignment"
    }
    4. Execute Operation Set


    And we are done :) Now the new task is created and user is assigned.
  • Erica J Ellis Profile Picture
    Erica J Ellis 58 on at
    How do we assign a person into a Project Task using Schedule API?
    I agree, the Project Team Member is different than the Resource record and does not have an availability calendar. The Project Team Member represents a single Resource on a Project, so the Project Team Member has a lookup to the specific Resource, where you find the availability calendar. The Project Team Member just acts as a middleman/intersection record, but it is required. A Project Team Member can have many Resource Assignments for a single Project as well.   So it might look something like this:
  • BP-16050313-0 Profile Picture
    BP-16050313-0 4 on at
    How do we assign a person into a Project Task using Schedule API?
    I to would be interested in knowing this. The example code in the documentation demonstrates how to create and assign a Team Member to a task. What I think I and Nandu are looking for is how to assign a bookable resource that is listed in the projects Resource tab. This Bookable Resource has a supporting availability calendar associated with it that can then be altered. The Team Member entity seems to be a very different thing and has no supporting availability calendar.
  • Suggested answer
    Erica J Ellis Profile Picture
    Erica J Ellis 58 on at
    How do we assign a person into a Project Task using Schedule API?
    A Resource Assignment record links the Project Task to a person. The Resource Assignment has a lookup column called msdyn_taskid that connects it to a Project Task record. It has a lookup column called msdyn_projectteamid that connects it to a Project Team Member record. The Project Team Member represents a single person. The Project Team Member record has a lookup to the Resource record. In general, your steps would be:
    1. Create the Project Task.
    2. Create the Project Team Member for the Resource assigned to the Project Task.
    3. Create the Resource Assignment to link the Project Task to the Project Team Member.

Helpful resources

Quick Links

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,700 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,058 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans