web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Assign a role to a team with a Create plugin

(0) ShareShare
ReportReport
Posted on by

Hi,

 

I want to deploy a Pre or Post Create plugin on the entity team.
The plugin must assign a role to the team.

I tried :

collectionReference.Add(new EntityReference("role", idRole));
_service.Associate(team.LogicalName, team.Id, new Relationship("teamroles_association"), collectionReference);

but i am getting a "Generic SQL Error"

I also tried to directly create the N:N association entity with :

Entity teamrole = new Entity();
teamrole.LogicalName = "teamroles";
teamrole["teamid"] = new EntityReference("team", team.Id);
teamrole["roleid"] = new EntityReference("role", idRole);
_service.Create(teamrole);

But then i get a The 'Create' method does not support entities of type 'teamroles'

Is there a way to assign the role at the creation of the team?

 

Thanks in advance

 

 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Deepesh161 Profile Picture
    6,317 on at

    msdn.microsoft.com/.../gg334359.aspx

  • Verified answer
    Daniel Wikell Profile Picture
    2,360 on at

    You will need to do this in a Post plugin since the team has to exist before you can assign a security role to it. A pre-plugin wouldn't work.

    If you follow the example from https://msdn.microsoft.com/en-us/library/gg334359.aspx then remember that you will receive multiple roles with the same name (one for each business unit) but only the role that belongs to the same business unit as the team will actually work. So don't forget to filter out the appropriate one.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans