To find all the records(say lead) shared with any particular user we can make use of following query
It will return us all records(lead) shared with the user directly( i.e. through Action–>Sharing and user)
select fl.subject
from
PrincipalObjectAccess poa , FilteredLead fl, FilteredSystemUser fsu
where
poa.ObjectTypeCode = 4
and poa.ObjectId = fl.leadid
and poa.PrincipalId = fsu.systemuserid
and fsu.domainname=SYSTEM_USER
// fsu.fullname=’name of user’
And to get the records shared with the user indirectly (i.e. through Action–>Sharing and Team (user belongs to that team)
select fl.subject
from
FilteredLead fl, PrincipalObjectAccess poa, FilteredTeam ft
where
poa.ObjectTypeCode = 4
and poa.ObjectId =fl.leadid
and poa.PrincipalId = ft.teamid and
fl.owneridname not in (select fullname from filteredsystemuser
where domainname=SYSTEM_USER)
and
ft.teamid in (select ft.teamid from filteredteammembership fm
, filteredsystemuser fsu, filteredteam ft
where fm.systemuserid=fsu.systemuserid and
ft.teamid=fm.teamid
and fsu.domainname=SYSTEM_USER
)
Bye
it really helped me thanks :]
LikeLike
can i do that via web services?
Is there any way to do that in “advanced find”?
thank you
LikeLike
principalObjectAccess is not available in advance find so can’t
try this and create custom xml
http://fxb.xrmtoolbox.com/
LikeLike
How can i retrieve this data from table PrincipalOBjectAccess on javascript? using oData json? could you help me ?
LikeLike
using odata json is not possible i guess try to create your desired fetchxml and use it.
http://fxb.xrmtoolbox.com/
LikeLike
It is a pity, that now I can not express – it is very occupied. I will be released – I will necessarily express the opinion on this question.
LikeLike