We can use RetrievePrincipalAccess function in Web API to get the access rights of either a user or team on a specific record.
The sample code:
var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/systemusers(D38F5B76-C22E-4256-AF90-CFD14B6589BF)"+ "/Microsoft.Dynamics.CRM.RetrievePrincipalAccess(Target =@Target)?"+ "@Target={ 'accountid': '8CB09F67-EB90-E811-A963-000D3AD1CBD6', '@odata.type': 'Microsoft.Dynamics.CRM.account' } ", false); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 200) { var results = JSON.parse(this.response); } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send();
Result:
Hope it helps..
One thought on “Sample code to use RetrievePrincipalAccess Function to get the access rights of the team or user in Dynamics 365 CE”