Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Find permissions of the logged in user on a SharePoint2013 list using JSOM

$
0
0

Hi I want to hide  add item link depending upon the logged in USER. So if the logged in User has contributing  rights then  then link should be visible. I want to achieve  the goal using java script (JSOM) on sharepoint 2013. I have tried the following script but it is not working for me. Help is highly appreciated.

<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script>
ExecuteOrDelayUntilScriptLoaded(foo,"sp.js");
var web;
var clientContext ;
var currentUser;
var projectList;
var perMask;
function foo()
{
    debugger;
    clientContext = new SP.ClientContext.get_current();
    web = clientContext.get_web();
    currentUser = web.get_currentUser();   
    projectList=web.get_lists().getByTitle('Projects');
       clientContext.load(projectList);
    clientContext.load(currentUser); 
    clientContext.load(web); 
       
   
 clientContext.executeQueryAsync(
        Function.createDelegate(this, this.onQuerySucceeded), 
        Function.createDelegate(this, this.onQueryFailed)
    );


}

function onQuerySucceeded()
{
  //perMask=projectList.getUserEffectivePermissions(currentUser.get_loginName());
  if (projectList.getUserEffectivePermissions(currentUser.get_loginName()).has(SP.PermissionKind.addListItems))
   alert(' you have permissions hi');
}


</script>


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>