locked
How to find which records are shared with particular user RRS feed

  • Question

  • Good Morning

    How can I find out how many accounts, opprtunities, contacts are shared with a particular user

    Is there a way to find this out? This is a handy feature when user is no longer with the company

    What happens to the shared records when we disable CRM user account?

    Thanks for your help in advance

     

    Thursday, October 28, 2010 3:47 PM

Answers

  • you can refer this thread for answer for finding shared records for particular user

    http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/6f017ae4-c376-4b47-b14d-6b81170a4682/#1cef5870-0635-4e0d-944d-806e19bb43e7


    Jai Ho CRM http://mscrmkb.blogspot.com Skype - amol.gholap

    Mark as answer if a post has answered the question
    • Marked as answer by Jim Glass Jr Monday, November 1, 2010 4:21 PM
    Thursday, October 28, 2010 3:51 PM
  • for account entity make  <condition attribute = 'objecttypecode' operator='eq' value='1 '/>

     

    string fetchxml = @"
    <fetch mapping='logical'>
     <entity name='principalobjectaccess'>
     <filter type='and'>
     <condition attribute = 'objecttypecode' operator='eq' value='1'/>
     <condition attribute = 'principalid' operator='eq' value='A0D54C73-B634-DE11-9B74-0003FF18DEBC'/>
     </filter>
     <link-entity name='opportunity' from='opportunityid' to='objectid'>
     <attribute name='name'/>
     </link-entity>
     </entity>
    </fetch>";


    Jai Ho CRM http://mscrmkb.blogspot.com Skype - amol.gholap

    Mark as answer if a post has answered the question
    • Marked as answer by Jim Glass Jr Monday, November 1, 2010 4:21 PM
    Thursday, October 28, 2010 4:12 PM
  • As stated in the post you should provide 2 parameters as input. (marked in red are your inputs)

    objecttypecode = accounts/opprtunities/contacts object type code.

    Userid =  GUID of the user to which you need to find the sharing record.

    You can also obtain the count (no of records shared for the user) by using aggregate option in fetchxml. For that you can refer here. (below code needs little modification to be done for that)

    Sample Code:

    Below code obtains all the accounts shared for the particular user (with guid 'A0D54C73-B634-DE11-9B74-0003FF18DEBC')

     

    string fetchxml = @"
    <fetch mapping='logical'>
     <entity name='principalobjectaccess'> 
     <filter type='and'>
     <condition attribute = 'objecttypecode' operator='eq' value='
    1'

     <condition attribute = 'principalid' operator='eq' value='A0D54C73-B634-DE11-9B74-0003FF18DEBC'

     </filter>
     <link-entity name='opportunity' from='opportunityid' to='objectid'>
     <attribute name='name'/>
     </link-entity>
     </entity>
    </fetch>";


    String result = CrmService.Fetch(fetchxml);


     

    • Marked as answer by Jim Glass Jr Monday, November 1, 2010 4:22 PM
    Thursday, October 28, 2010 5:03 PM

All replies

  • you can refer this thread for answer for finding shared records for particular user

    http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/6f017ae4-c376-4b47-b14d-6b81170a4682/#1cef5870-0635-4e0d-944d-806e19bb43e7


    Jai Ho CRM http://mscrmkb.blogspot.com Skype - amol.gholap

    Mark as answer if a post has answered the question
    • Marked as answer by Jim Glass Jr Monday, November 1, 2010 4:21 PM
    Thursday, October 28, 2010 3:51 PM
  • Thanks for the link Amol.
    There is a code to run in Vinoth's post as listed below but I am not sure where and how to apply/run this cose.
    Can you please guide me further?

    value = 'A0D54C73-B634-DE11-9B74-0003FF18DEBC'/ is user ID, correct?
    Can I use the same code for Account entity?


    string fetchxml = @"
    <fetch mapping='logical'>
     <entity name='principalobjectaccess'>
     <filter type='and'>
     <condition attribute = 'objecttypecode' operator='eq' value='3'/>
     <condition attribute = 'principalid' operator='eq' value='A0D54C73-B634-DE11-9B74-0003FF18DEBC'/>
     </filter>
     <link-entity name='opportunity' from='opportunityid' to='objectid'>
     <attribute name='name'/>
     </link-entity>
     </entity>
    </fetch>";

     

    Thursday, October 28, 2010 4:07 PM
  • for account entity make  <condition attribute = 'objecttypecode' operator='eq' value='1 '/>

     

    string fetchxml = @"
    <fetch mapping='logical'>
     <entity name='principalobjectaccess'>
     <filter type='and'>
     <condition attribute = 'objecttypecode' operator='eq' value='1'/>
     <condition attribute = 'principalid' operator='eq' value='A0D54C73-B634-DE11-9B74-0003FF18DEBC'/>
     </filter>
     <link-entity name='opportunity' from='opportunityid' to='objectid'>
     <attribute name='name'/>
     </link-entity>
     </entity>
    </fetch>";


    Jai Ho CRM http://mscrmkb.blogspot.com Skype - amol.gholap

    Mark as answer if a post has answered the question
    • Marked as answer by Jim Glass Jr Monday, November 1, 2010 4:21 PM
    Thursday, October 28, 2010 4:12 PM
  • Thanks again Amol, much appreciated

    you answered my one question but still not sure how and where to run this code

    Can you please guide me for that as well?

    Thursday, October 28, 2010 4:16 PM
  • You need records shared by user:

    you will execute fetchXml request using CrmService.Fetch(fetchXmlQuery). This will return back XML file which all data.

    You need to parse XML file to get shared records. refer CRM Sdk for more details or you can just google it you will find lot of links.

    You can also refer below link

    http://msdn.microsoft.com/en-us/library/bb928434.aspx


    Jai Ho CRM http://mscrmkb.blogspot.com Skype - amol.gholap

    Mark as answer if a post has answered the question
    Thursday, October 28, 2010 4:30 PM
  • As stated in the post you should provide 2 parameters as input. (marked in red are your inputs)

    objecttypecode = accounts/opprtunities/contacts object type code.

    Userid =  GUID of the user to which you need to find the sharing record.

    You can also obtain the count (no of records shared for the user) by using aggregate option in fetchxml. For that you can refer here. (below code needs little modification to be done for that)

    Sample Code:

    Below code obtains all the accounts shared for the particular user (with guid 'A0D54C73-B634-DE11-9B74-0003FF18DEBC')

     

    string fetchxml = @"
    <fetch mapping='logical'>
     <entity name='principalobjectaccess'> 
     <filter type='and'>
     <condition attribute = 'objecttypecode' operator='eq' value='
    1'

     <condition attribute = 'principalid' operator='eq' value='A0D54C73-B634-DE11-9B74-0003FF18DEBC'

     </filter>
     <link-entity name='opportunity' from='opportunityid' to='objectid'>
     <attribute name='name'/>
     </link-entity>
     </entity>
    </fetch>";


    String result = CrmService.Fetch(fetchxml);


     

    • Marked as answer by Jim Glass Jr Monday, November 1, 2010 4:22 PM
    Thursday, October 28, 2010 5:03 PM
  • Thanks Vinoth
    Tuesday, November 2, 2010 1:28 PM
  • How can i retrieve the records from PrincipalObjectAcess by javascript?

    i tried via o data but not successful. I dont understand why? because for other entities its ok! 

    here is the code.

    $.ajax({
                    type: "GET",
                    contentType: "application/json; charset=utf-8",
                    datatype: "json",
                    async: false,
                    url: Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc/PrincipalObjectAccessSet?$select=ObjectId&$filter=PrincipalId eq guid'"+TeamId+"'",
                    beforeSend: function (XMLHttpRequest) {
                        XMLHttpRequest.setRequestHeader("Accept", "application/json");
                    },
                    success: function (data, textStatus, XmlHttpRequest) {
                        var sharedQueue = data.d;
    ObjectId = sharedQueue.results[0].ObjectId;
    }
                });

    obs: PrincipalId = TeamId

    Monday, May 20, 2013 12:50 PM