Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Sharing Records

Posted on by 230

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

  • Suggested answer
    Emre GULCAN Profile Picture
    Emre GULCAN 2,379 on at
    RE: Sharing Records

    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)
       }
    }
  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Sharing Records

    Hi ,

    You can also check below reference  after retrieving the user or team how to share the records.

    missdynamicscrm.blogspot.in/.../crm-20112013-share-and-un-share-records-programmatically-C-sharp.html

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Sharing 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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans