viernes, 13 de septiembre de 2013

CRM 4.0 - Como compartir entidades

                       Equipo = (team)teams.BusinessEntities[0];

                        // Create the SecurityPrincipal Object
                        SecurityPrincipal principal = new SecurityPrincipal();
                        principal.Type = SecurityPrincipalType.Team;

                        // PrincipalId is the Guid of the user to whom access is being granted
                        principal.PrincipalId = Equipo.teamid.Value;

                        // Create the PrincipalAccess Object
                        PrincipalAccess principalAccess = new PrincipalAccess();

                        // Set the PrincipalAccess Object's Properties
                        principalAccess.Principal = principal;

                        // Gives the principal access to read
                        principalAccess.AccessMask = AccessRights.ReadAccess;
                        principalAccess.AccessMask |= AccessRights.WriteAccess;
                        principalAccess.AccessMask |= AccessRights.DeleteAccess;
                        principalAccess.AccessMask |= AccessRights.AssignAccess;
                        principalAccess.AccessMask |= AccessRights.AppendAccess;
                        principalAccess.AccessMask |= AccessRights.AppendToAccess;

                        // Create the Target Object for the Request
                        TargetOwnedContact target = new TargetOwnedContact();

                        // EntityId is the Guid of the account access is being granted to
                        target.EntityId = contacto_p.Value;

                        // Create the Request Object
                        GrantAccessRequest grant = new GrantAccessRequest();

                        // Set the Request Object's properties
                        grant.PrincipalAccess = principalAccess;
                        grant.Target = target;

                        // Execute the Request
                        GrantAccessResponse granted = (GrantAccessResponse)crmService.Execute(grant);

No hay comentarios:

Publicar un comentario