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)

Issue Add user in Team Template C# code

(0) ShareShare
ReportReport
Posted on by 195

I have the following business logic:

When you add a record the fields required attendees and optional attendees, must check that these records are system user type, then insert them in an access team template, this in the entity appoitment. This is my code; however, when executing it I get the following error: Privilege Type Share not defined on entity 'SystemUser'

private static void regardinCitas()
{


Entity cita = _service.Retrieve("appointment", new Guid("A9E39164-4980-E811-942F-00505681106C"), new ColumnSet(true));

if (cita.Attributes.Contains("requiredattendees") || cita.Attributes.Contains("optionalattendees"))
{

EntityCollection requeridos = cita.GetAttributeValue<EntityCollection>("requiredattendees");
EntityCollection opcionales = cita.GetAttributeValue<EntityCollection>("optionalattendees");

EntityCollection usuariosParticipantes = new EntityCollection();

foreach (Entity partR in requeridos.Entities)
{
if (partR.GetAttributeValue<EntityReference>("partyid").LogicalName == "systemuser")
{
usuariosParticipantes.Entities.Add(partR);
}
}

foreach (Entity partO in opcionales.Entities)
{
if (partO.GetAttributeValue<EntityReference>("partyid").LogicalName == "systemuser")
{
usuariosParticipantes.Entities.Add(partO);
}
}


foreach(Entity usuario in usuariosParticipantes.Entities)
{
AddUserToRecordTeamRequest teamAddRequest = new AddUserToRecordTeamRequest();
teamAddRequest.Record = new EntityReference("systemuser",usuario.GetAttributeValue<EntityReference>("partyid").Id);
teamAddRequest.SystemUserId = usuario.GetAttributeValue<EntityReference>("partyid").Id;
teamAddRequest.TeamTemplateId = new Guid("2A25FF10-F0F2-E811-9437-00505681106C");
_service.Execute(teamAddRequest);
}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    You have issues on line here:

    teamAddRequest.Record = new EntityReference("systemuser",usuario.GetAttributeValue<EntityReference>("partyid").Id);

    Instead of putting reference of user there you should put reference of entity you want to enable TeamAccess like opportunity or so.

  • Zucko_mac Profile Picture
    195 on at

    thanks you works perfectly

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