Skip to content

Instantly share code, notes, and snippets.

@vaderj
Last active June 12, 2018 16:56
Show Gist options
  • Save vaderj/936ee48528ddaba08ae0ef7f27e2ed2b to your computer and use it in GitHub Desktop.
Save vaderj/936ee48528ddaba08ae0ef7f27e2ed2b to your computer and use it in GitHub Desktop.
check if the current SP user has a specific permission #Javascript #REST #SharePoint
//Permission enumeration : https://msdn.microsoft.com/en-us/library/office/ee556747(v=office.14).aspx
function checkPermissions() {
var call = jQuery.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/effectiveBasePermissions",
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
}
});
call.done(function (data, textStatus, jqXHR) {
var manageListsPerms = new SP.BasePermissions();
manageListsPerms.initPropertiesFromJson(data.d.EffectiveBasePermissions);
var approveItems = manageListsPerms.has(SP.PermissionKind.approveItems);
//console.log(approveItems);
if (approveItems == true){return true}
else{return false};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment