1

Im trying to reset a list's inheritance using javascript and Sharepoint 2010.

Here is my code so far:

<script language="JavaScript">
<!--  
var vcms_currentCTX;
var vcms_currentWEB;
var vcms_lists;
var vcms_list;
var vcms_listID;

function sharePointReady()
{
  vcms_listID       = document.getElementById("listID").value;

  vcms_currentCTX  = SP.ClientContext.get_current();
  vcms_currentWEB  = vcms_currentCTX.get_web();
  vcms_lists = vcms_currentWEB.get_lists();
  vcms_list = vcms_lists.getById(vcms_listID);

  vcms_list.resetRoleInheritance();

  vcms_currentCTX.load(vcms_list);

    vcms_currentCTX.executeQueryAsync(
      Function.createDelegate(this, fcms_onRequestSucceeded2),
      Function.createDelegate(this, fcms_onRequestFailed));
}

function fcms_onRequestSucceeded2() {
}

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

I know I probably dont need to load and executeQueryAsync for this (using list.update() should be enough).

This code gives me the error

"The object doesnt support this property or method"

But I have seen the method being used in list objects somewhere else (i think it was on PowerShell).

Is ResetRoleInheritance not supported in javascript or my sharepoint version?

1 Answer 1

0

resetRoleInheritance() method is present in SharePoint 2010 JavaScript client object model and it resets the role inheritance for the securable object and inherits role assignments from the parent securable object. SP.List inherits from SP.SecurableObject Class. Hence resetRoleInheritance() can be called on SP.List object just like breakRoleInheritance. I don't have SP 2010 available. However, I ran the your code in SP 2013 and it worked perfectly. See this for more information:

https://msdn.microsoft.com/en-us/library/office/ff412028(v=office.14).aspx

1
  • Like many things in life, it magically worked now. Sigh, I hate when these things happen... But thanks for making me run the code again ! :D
    – Diego
    Commented Jul 17, 2015 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.