Monday, January 21, 2013

Get shared records for a User/Team in MS CRM 2011


Get shared records for a User/Team:

We get very frequent requirement on how to get the shared records for a User/Team in Plugin/web application using CRM SDK/service.

I prepared below fetchXML which returns all shared records of an entity for a user/Team.

Its a generic fetchXML. Just we need to replace 3 value.
1. Entity name (just replace account with any crm entity).
2. Primary field (for account it is accountid). It is used to join principalobjectaccess and the entity. So just provide the entity primary field in "to".
3. User/Team GUID. (just replace the user/team GUID in value).

<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
  <entity name='account'>
<link-entity name='principalobjectaccess' to='accountid' from='objectid' link-type='inner' alias='share'>
<filter type='and'>
<condition attribute='principalid' operator='eq' value='E36D3084-8135-E211-AC03-000C29AD15D1' />
</filter>
</link-entity>
  </entity>
</fetch>

4 comments:

Maya Iyer said...

Got this.
I have an entity for which there are two views say one Active accounts and My active accounts.

My active accounts will show all the records belonging to the current user.

Say i have shared some account with the above mentioned user. I want this shared record to be seen in the my active accounts view.

With the example given by you, i am able to see the shared record in the Active Accounts view.

Is there any other way wherein I can see the shared record in the My Active Accounts view.

Pls help.

Omega software said...

Keep up the fantastic piece of work, I read few blog posts on this web site and I believe that your site is real interesting and has lots of great information. ERP Software in Mumbai || System Software || CRM Software in Mumbai || MLM Software

Omega software said...

I really appreciate spending some time to talk about that, I believe firmly regarding this and so really enjoy understanding more about this kind of subject.This is also a very good post which I really enjoyed reading. It is not everyday that I have the possibility to see something like this. CRM Software || MLM Software in Mumbai || ERP Software || System Software in Mumbai

Vasu Sundaran said...

That's really wonderful....I loved it ..... For best MLM Software Visit MLM Software