Posts Tagged ‘Microsoft Dynamics CRM’

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

Here in the query one more condition is added which is when the Rating is Hot. 

select leadqualitycodename,* from filteredlead As fl inner join dbo.FilteredActivityParty as fap
ON fl.leadid=fap.partyid
and fl.leadid=‘yourleadid’ and leadqualitycodename=‘Hot’ 

To find the opportunity record shared with a particular user in Microsoft Dynamics Crm

select o.name as OpportunityName,p.AccessRightsMask from opportunityBase o
left join PrincipalObjectAccess
p on p.objectid=o.opportunityid left join systemuser u
on p.principalid=u.systemuserid where u.fullname=’nishant r’

or u.domainname=SYSTEM_USER

AccessRightsMask values and what they mean

AppendAccess 4 - Specifies the right to append the specified object to another object.
AppendToAccess 8 - Specifies the right to append another object to the specified object.
AssignAccess 0×80 -Specifies the right to assign the specified object to another security principal.
CreateAccess 0×10 -Specifies the right to create an instance of the object type.
DeleteAccess 0×20 -Specifies the right to delete the specified object.
ReadAccess 1 -Specifies the right to read the specified type of object.
ShareAccess 0×40 -Specifies the right to share the specified object.
WriteAccess 2 - Specifies the right to update (write to) the specified object.

3- Read + Write

65539- Read + Write + Delete

851991- All the rights

262145- Share+Read etc…

फिर मिलते हें
Bye