Forum Discussion

PatrickGrebe's avatar
PatrickGrebe
Copper Contributor
Feb 03, 2022

Create Project via msdyn_CreateProjectV1 and assign an microsoft 365 group

Hello,

 

in our environment we are creating projects in P4W via the msdyn_CreateProjectV1 api with an azure function. This is working fine.

 

Unfortunately we cannot find a solution to connect a microsoft 365 group with the created project.

If you do it in the webinterface it creates a post request against

 

https://oneproject-prod-torus-neu-000.northeurope.cloudapp.azure.com/pss/api/v1.0/projects(msxrm_ORGNAME.crm4.dynamics.com_PROJECTID)/shareProject

 

We've recreated that HTTP-POST in the azure function, and it also returns a success, but the group isn't assigned.

 

Is there any other possibility/API? 🙂

  • PatrickGrebe's avatar
    PatrickGrebe
    Copper Contributor

    We have now solved the whole thing using an Azure Function (within a Logic App) and corresponding C# code.

    We create a team and link it to an AAD group. The team is then assigned the appropriate security role. (https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/org-service/sample-assign-record-new-owner?view=op-9-1)

     

     

     

     

    var projectteam = new Entity("team", Guid.NewGuid());
    projectteam["name"] = officeGroupName;
    projectteam["businessunitid"] = new EntityReference("businessunit",Guid.Parse("GUID_BUSINESSUNIT_HERE"));
    projectteam["azureactivedirectoryobjectid"] = officeGroupId;
    projectteam["teamtype"] = 3;
    projectteam["membershiptype"] = 0;
    projectteam.Id = crmServiceClient.Create(projectteam);
    
    // Add the role to the team.
    crmServiceClient.Associate(
        "team",
        projectteam.Id,
        new Relationship("teamroles_association"),
        new EntityReferenceCollection() { new EntityReference("role", Guid.Parse("SEC-ROLE-GUID-HERE")) });

     

     

     

     

    We then create the project with the API "msdyn_CreateProjectV1". Here we then set the "ownerid" to the ID of the created team.

     

     

     

     

    project["ownerid"] = new EntityReference("team", Guid.Parse(projectteam.Id.ToString()));

     

     

     

    It takes some time until the connection is shown in P4W.

    • MarvinTheAndroid's avatar
      MarvinTheAndroid
      Copper Contributor

      PatrickGrebe I've been trying to do this with the dynamics REST API. 

      I can create the team using the same parameters as you have, and then create the project owned by the team.

       

      Did you ever find anything to help with "It takes some time until the connection is shown in P4W"?

       

      I'm finding it takes about an hour before project for the web recognises the association with the O365 group. 

      But worse, I'm finding that it doesn't work until after that hour I have to click on "group members" in the top right of P4W, at which point it says "loading members information"

      ... but doesn't ... until I then reload the project page at which point the group association has completed, and the project is now associated with the O365 group as expected

       

      • PatrickGrebe's avatar
        PatrickGrebe
        Copper Contributor
        No, unfortunately we did not find a solution for this. For us, however, this is not really time-critical.

Resources