Skip to content

Instantly share code, notes, and snippets.

@vaderj
Last active June 12, 2018 15:03
Show Gist options
  • Save vaderj/4e6e76eff437427d79ec7c119343b941 to your computer and use it in GitHub Desktop.
Save vaderj/4e6e76eff437427d79ec7c119343b941 to your computer and use it in GitHub Desktop.
SP REST: Break role inheritance on a folder #Javascript #REST #SharePoint
function breakroleinheritance(folderName)
{// https://mysite/_api/web/GetFolderByServerRelativeUrl('/DocLib/folder1')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true,clearSubscopes=true)
var breakPerms = jQuery.ajax({
//URL to just break inheritance
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('/p/flonboarding/Secured/" + folderName + "')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true,clearSubscopes=true)",
// URL to remove all perms
//url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('/p/flonboarding/Secured/" + folderName + "')/ListItemAllFields/breakroleinheritance/",
type: 'POST',
headers: {
'X-RequestDigest': $("#__REQUESTDIGEST").val()
}
});
breakPerms.done(function(listData, textStatus, jqXHR)
{
console.dir(listData) ;
console.dir(textStatus) ;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment