I want to see the list of users and teams to which a record is shared. I only want to see the list of users and teams that are given access to a record through the share button and not through the security role.
I am aware of the RetrieveSharedPrincipalsAndAccessRequest function. But, I don't want to write a plugin or create a custom action.
My question is how can I use the 'RetrieveSharedPrincipalsAndAccessRequest' function as a REST API?
The PrincipalAccessObject table holds the sharing data and you can query it.
E.g. by using FetchXml:
<fetch>
<entity name='principalobjectaccess'>
<attribute name='objectid' />
<attribute name='objecttypecode' />
<attribute name='accessrightsmask' />
<link-entity name='systemuser' to='principalid' from='systemuserid' alias='u' link-type='outer'>
<attribute name='systemuserid' />
<attribute name='fullname' alias='user' />
</link-entity>
<link-entity name='team' to='principalid' from='teamid' alias='t' link-type='outer'>
<attribute name='teamid' />
<attribute name='name' alias='team' />
</link-entity>
<filter>
<condition attribute='objectid' operator='eq' value='{OBJECT-ID}' />
</filter>
</entity>
</fetch>
The access rights mask is a flag enum. Documentation on it can be found on MS Learn.