Create Project via msdyn_CreateProjectV1 and assign an microsoft 365 group

%3CLINGO-SUB%20id%3D%22lingo-sub-3110215%22%20slang%3D%22de-DE%22%3ECreate%20Project%20via%20msdyn_CreateProjectV1%20and%20assign%20an%20microsoft%20365%20group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3110215%22%20slang%3D%22de-DE%22%3E%3CP%3EHello%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ein%20our%20environment%20we%20are%20creating%20projects%20in%20P4W%20via%20the%20msdyn_CreateProjectV1%20api%20with%20an%20azure%20function.%20This%20is%20working%20fine.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUnfortunately%20we%20cannot%20find%20a%20solution%20to%20connect%20a%20microsoft%20365%20group%20with%20the%20created%20project.%3C%2FP%3E%3CP%3EIf%20you%20do%20it%20in%20the%20webinterface%20it%20creates%20a%20post%20request%20against%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Foneproject-prod-torus-neu-000.northeurope.cloudapp.azure.com%2Fpss%2Fapi%2Fv1.0%2Fprojects(msxrm_ORGNAME.crm4.dynamics.com_PROJECTID)%2FshareProject%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Foneproject-prod-torus-neu-000.northeurope.cloudapp.azure.com%2Fpss%2Fapi%2Fv1.0%2Fprojects(msxrm_ORGNAME.crm4.dynamics.com_PROJECTID)%2FshareProject%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe've%20recreated%20that%20HTTP-POST%20in%20the%20azure%20function%2C%20and%20it%20also%20returns%20a%20success%2C%20but%20the%20group%20isn't%20assigned.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20any%20other%20possibility%2FAPI%3F%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3212924%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Project%20via%20msdyn_CreateProjectV1%20and%20assign%20an%20microsoft%20365%20group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3212924%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20have%20now%20solved%20the%20whole%20thing%20using%20an%20Azure%20Function%20(within%20a%20Logic%20App)%20and%20corresponding%20C%23%20code.%3C%2FP%3E%3CP%3EWe%20create%20a%20team%20and%20link%20it%20to%20an%20AAD%20group.%20The%20team%20is%20then%20assigned%20the%20appropriate%20security%20role.%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdynamics365%2Fcustomerengagement%2Fon-premises%2Fdeveloper%2Forg-service%2Fsample-assign-record-new-owner%3Fview%3Dop-9-1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdynamics365%2Fcustomerengagement%2Fon-premises%2Fdeveloper%2Forg-service%2Fsample-assign-record-new-owner%3Fview%3Dop-9-1%3C%2FA%3E)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Evar%20projectteam%20%3D%20new%20Entity(%22team%22%2C%20Guid.NewGuid())%3B%0Aprojectteam%5B%22name%22%5D%20%3D%20officeGroupName%3B%0Aprojectteam%5B%22businessunitid%22%5D%20%3D%20new%20EntityReference(%22businessunit%22%2CGuid.Parse(%22GUID_BUSINESSUNIT_HERE%22))%3B%0Aprojectteam%5B%22azureactivedirectoryobjectid%22%5D%20%3D%20officeGroupId%3B%0Aprojectteam%5B%22teamtype%22%5D%20%3D%203%3B%0Aprojectteam%5B%22membershiptype%22%5D%20%3D%200%3B%0Aprojectteam.Id%20%3D%20crmServiceClient.Create(projectteam)%3B%0A%0A%2F%2F%20Add%20the%20role%20to%20the%20team.%0AcrmServiceClient.Associate(%0A%20%20%20%20%22team%22%2C%0A%20%20%20%20projectteam.Id%2C%0A%20%20%20%20new%20Relationship(%22teamroles_association%22)%2C%0A%20%20%20%20new%20EntityReferenceCollection()%20%7B%20new%20EntityReference(%22role%22%2C%20Guid.Parse(%22SEC-ROLE-GUID-HERE%22))%20%7D)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20then%20create%20the%20project%20with%20the%20API%20%22msdyn_CreateProjectV1%22.%20Here%20we%20then%20set%20the%20%22ownerid%22%20to%20the%20ID%20of%20the%20created%20team.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eproject%5B%22ownerid%22%5D%20%3D%20new%20EntityReference(%22team%22%2C%20Guid.Parse(projectteam.Id.ToString()))%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20takes%20some%20time%20until%20the%20connection%20is%20shown%20in%20P4W.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

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

 

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? :)

3 Replies

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/sa...)

 

 

 

 

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.

@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

 

No, unfortunately we did not find a solution for this. For us, however, this is not really time-critical.