Hi All,
(Eg)
Consider there is an Account, which was shared with some users, if you want to know the users in CRM Plugins or console app, use this
Call the below code as
ProcessSharedUser(Service);
public void ProcessSharedUser(IOrganizationService service)
{
PrincipalAccess[] sharedUsersOfAccount = getSharedUsersforAccount("account", new Guid(""), service);
if (sharedUsersOfAccount.Length > 0)
{
for (int i = 0; i < sharedUsersOfAccount.Length; i++)
{
getUserList sharedUsersOfAccount[i].Principal.Id;
}
}
}
public PrincipalAccess[] getSharedUsersforAccount(string entityName, Guid accountId, IOrganizationService service)
{
RetrieveSharedPrincipalsAndAccessRequest retrieveSharedRequest = new RetrieveSharedPrincipalsAndAccessRequest()
{
Target = new EntityReference(entityName, accountId)
};
RetrieveSharedPrincipalsAndAccessResponse retrieveSharedResponse = (RetrieveSharedPrincipalsAndAccessResponse)service.Execute(retrieveSharedRequest);
return retrieveSharedResponse.PrincipalAccesses;
}
(Eg)
Consider there is an Account, which was shared with some users, if you want to know the users in CRM Plugins or console app, use this
Call the below code as
ProcessSharedUser(Service);
public void ProcessSharedUser(IOrganizationService service)
{
PrincipalAccess[] sharedUsersOfAccount = getSharedUsersforAccount("account", new Guid(""), service);
if (sharedUsersOfAccount.Length > 0)
{
for (int i = 0; i < sharedUsersOfAccount.Length; i++)
{
getUserList sharedUsersOfAccount[i].Principal.Id;
}
}
}
public PrincipalAccess[] getSharedUsersforAccount(string entityName, Guid accountId, IOrganizationService service)
{
RetrieveSharedPrincipalsAndAccessRequest retrieveSharedRequest = new RetrieveSharedPrincipalsAndAccessRequest()
{
Target = new EntityReference(entityName, accountId)
};
RetrieveSharedPrincipalsAndAccessResponse retrieveSharedResponse = (RetrieveSharedPrincipalsAndAccessResponse)service.Execute(retrieveSharedRequest);
return retrieveSharedResponse.PrincipalAccesses;
}
No comments:
Post a Comment