Sample code to use RetrievePrincipalAccess Function to get the access rights of the team or user in Dynamics 365 CE


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..

Advertisements

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

Please share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.