I.Add Script two files
1.jquery-1.8.2.min.js
2.jquery.SPServices-0.7.2.min.js
in the bellow Content Place Holder
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script type="text/javascript" src="../../SiteAssets/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../../SiteAssets/js/jquery.SPServices-0.7.2.min.js"></script>
II. Call function in the document.Ready function
using following code we can check user permission (edit) on a specific list
var _currentUser;
var _theList;
function Editpermissions()
{
context = new SP.ClientContext.get_current();
web = context.get_web();
this._currentUser = web.get_currentUser();
// here mention list name ex: employee
this._theList = web.get_lists().getByTitle('employee');
context.load(this._currentUser);
context.load(_theList, 'EffectiveBasePermissions');
context.executeQueryAsync(Function.createDelegate(this, Success), Function.createDelegate(this, Failure));
}
function Success()
{
if (this._theList.get_effectiveBasePermissions().has(SP.PermissionKind.editListItems))
{
alert('User Can Edit the list.');
}
else
{
alert('User Can NOT Edit the list.');
}
}
function Failure()
{
alert('unable to perform the action');
}
using following code we can check user permission (edit) on a specific web
function checkpermission()
{
var context;
context = new SP.ClientContext.get_current();
web = context.get_web();
context.load(web, 'EffectiveBasePermissions');
context.executeQueryAsync(onSuccess, onFailure);
}
function onSuccess()
{
if (web.get_effectiveBasePermissions().has(SP.PermissionKind.manageWeb))
{
alert('User Can Edit the list.');
}
}
function onFailure()
{
alert('unable to perform the action');
}
No comments:
Post a Comment