Dear Communities,
I have 1000 of account record GUIDs, want to know these records are shared to any team or any user.
Is there any programmatic way to approach?
Thanks & Regards,
Dan
*This post is locked for comments
Hi,
You can do this with "RetrieveSharedPrincipalsAndAccessRequest", please look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.retrievesharedprincipalsandaccessrequest.aspx for more information.
Sample code is below;
RetrieveSharedPrincipalsAndAccessRequest request = new RetrieveSharedPrincipalsAndAccessRequest() { Target = new EntityReference(entityLogicalName, recordId) }; var serviceResponse = (RetrieveSharedPrincipalsAndAccessResponse)IOrganizationService.Execute(request);
You can also use XrmLibrary (2015 or 2016) and just do it with simple 2 lines below (blue lines optional process)
CommonHelper commonHelper = new CommonHelper(_organizationService);
var sharedPrincipalList = commonHelper.GetSharedPrincipalsAndAccess(Guid.Parse("RECORD ID"), "ENTITY LOGICAL NAME");
if (sharedPrincipalList != null && sharedPrincipalList.Count > 0)
{
foreach (var item in sharedPrincipalList)
{
var principalInfo = item.Principal; //This returns EntityReference, so you can get PrincipalType (Team or SystemUser) and Id (for Team or SystemUser)
}
}
Hi ,
You can also check below reference after retrieving the user or team how to share the records.
Hi Dans,
since you are using crm online.
Use below fetchxml to find all the record that shared to user, but of course you have to change a little bit.
ps: you can create as a ssrs report.
mscrm-chandan.blogspot.my/.../get-shared-records-for-userteam.html
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156