none
In O365, How to restrict delete access to all users except the login user? RRS feed

  • Question

  • Using Jquery and CSR developed Create,Edit and Display forms. 

    Scenario:In the create form, i have study(text),category(dropdown)  and some other fields. Buttons are CreateFolder and Save.

    First i click on CreateFolder after click on save button. each item CreateFolder click i have created  folders under study(first folder)/category(second folder)/3folders(three folders)  each time based on Drop down Category.As per the requirement, i have  to restrict delete access to all users except the login user.

    in my case i have a many user folders in each category.I have to restrict delete permissions to remaining all users and able to delete or edit only my folders except others.

    Logged in user only have access on his own folder creations and for remaining users no access(only read access).

    Please help.

    Monday, July 2, 2018 1:01 PM

All replies

  • Hi,

    For OOB function, you could check item-level Permissions in list advanced settings.


    Best Regards,

    Lee


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Tuesday, July 3, 2018 2:52 AM
  • Hi,

    This is a Document Library having Folder Structure.We have to apply logic on Folder level.

    Please help through jqeury code/Out of box?

    Tuesday, July 3, 2018 7:35 AM
  • Hi,

    You could break permission for folder by JSOM, for example:

    function breakItemPermission(listName, listItemID, groupName) {
     
        var clientContext = new SP.ClientContext();
        oList = clientContext.get_web().get_lists().getByTitle(listName);
        oListItem = oList.getItemById(listItemID);
     
        //Below line breaks the ListItem permission inheritance
        oListItem.breakRoleInheritance(false);
     
        //Bind Contribute permission to the Group
        oGroup = clientContext.get_web().get_siteGroups().getByName(groupName);
        var groupPermissionBinding = SP.RoleDefinitionBindingCollection.newObject(clientContext);
        groupPermissionBinding.add(clientContext.get_web().get_roleDefinitions().getByType(SP.RoleType.contributor));
     
        //Assign binded permission to the page or listitem
        oListItem.get_roleAssignments().add(oGroup, collRoleDefinitionBinding);
     
        clientContext.load(oListItem);
     
        clientContext.executeQueryAsync(
            Function.createDelegate(this, function() {
                alert('Applied the unique permission and assigns contribute permission to the group');
            }),
            Function.createDelegate(this, function(sender, args) {
                alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
            }));
    }
     
    function injectMethod() {
        breakItemPermission("TestList",2,"ktskumar Visitors");
    }
    ExecuteOrDelayUntilScriptLoaded(injectMethod, "sp.js");

    Here is the thread for your reference.

    http://www.ktskumar.com/2017/10/want-break-permission-sharepoint-using-jsom/

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Tuesday, July 3, 2018 8:20 AM