Script to Stop List Permissions Inheritance via API


setStopListPermissionsInheritance: function(item, beforeComplete) {
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
var curUser = web.get_currentUser(); 
var list = ctx.get_web().get_lists().getByTitle(listName);
ctx.load(list);
var lstItem = list.getItemById(item.id);
lstItem.breakRoleInheritance(true, false);
lstItem.update();

ctx.executeQueryAsync(onStopInheritPermissionsComplete, this.onSPExecFail);

function onStopInheritPermissionsComplete (sender, args) {
var options = SP.UI.$create_DialogOptions();
options.title = "Grant Permissions";
options.url = String.format("/_layouts/aclinv.aspx?obj={0},{1},FOLDER&List={0}&IsDlg=1",list.get_id(), item.id);
SP.UI.ModalDialog.showModalDialog(options);
}
}

Tagged with: ,
Posted in 2010, JavaScript, Microsoft SharePoint Server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Antek Group Blog
Categories
%d bloggers like this: