Question

I have a list where I want give edit permissions at item level. I am aware of the item level permissions offered by SharePoint.

What I am looking for is that I should be able to assign editing rights for an item in list to a specific user or group of users. The item should have read access for everyone.

Is this possible in SharePoint 2013?

Update 1: Is this operation possible via SharePoint API? I checked the SPListItem on MSDN but couldn't find it. I am preferably looking for JavaScript or REST API.

Was it helpful?

Solution 2

I should have searched a bit more!

I found this MSDN article which details out how to do it in JSOM. I was able to create sample code for myself. Posting it here to help others.

function breakInheritance() {
    var clientContext = new SP.ClientContext.get_current();

    var oList = clientContext.get_web().get_lists().getByTitle('TestList');

    this.item = oList.getItemById(2);

    // Break inheritance. If argument is 'true' then parent list
    // permissions are kept as is. If 'false' then parent list 
    // permission are removed.
    item.breakRoleInheritance(true);

    this.oUser = clientContext.get_web().ensureUser('DOMAIN\\user');
    var collRoleDefinitionBinding = SP.RoleDefinitionBindingCollection.newObject(clientContext);
    this.roleDefs = clientContext.get_web().get_roleDefinitions();

    //Assign 'Reader' permission level to user
    //collRoleDefinitionBinding.add(roleDefs.getByType(SP.RoleType.reader));

    //Assign '<CUSTOM PERMISSION LEVEL>' permission level to user
    collRoleDefinitionBinding.add(roleDefs.getByName("<CUSTOM PERMISSION LEVEL>"));

    item.get_roleAssignments().add(oUser, collRoleDefinitionBinding);

    clientContext.load(oUser);
    clientContext.load(item);

    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded(sender, args) {
    console.log(item);

}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

OTHER TIPS

Yes, this is possible in SharePoint 2013.

You can follow the below steps:

  1. Go to the list where you want to assign item level permissions.
  2. Select the Item in which you have to provide the permissions.
  3. Then click on the ellipses -> Advanced -> Shared With and a new pop up will appear. enter image description here

  4. In the pop up, click on the Advanced button. enter image description here

  5. The permission groups for the item will be displayed on the page. Click on Stop Inheriting Permissions. enter image description here

  6. Now you can add the user in any of the groups for the permissions that you want to provide for this particular item and can continue for the remaining ones.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top