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