Monday 21 October 2013

Check current user permissions using jsom

function checkifUserHasEditPermissions() {
context = new SP.ClientContext.get_current();
web = context.get_web();
this._currentUser = web.get_currentUser();
context.load(this._currentUser);
context.load(web,'EffectiveBasePermissions');
context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), Function.createDelegate(this, this.onFailureMethod));
}
function onSuccessMethod(sender, args) 
{
if (web.get_effectiveBasePermissions().has(SP.PermissionKind.editListItems)) 
{
//User Has Edit Permissions
}
}}

No comments:

Post a Comment