1

I'm trying to make a JSOM utility that will allow me to alter the properties of pre-existing document libraries. So far I have successfully managed to update the list 'Title' and 'Description' properties.

The bit I am stuck on is how can I update the URL for the list to a value of my choosing?

I have had a look already at this MSDN advice on the List Object. There are no pre-existing methods that I can use to update the URL.

Is there a way of doing this in JSOM in SharePoint or have I hit a dead end? Any help would be very much appreciated.

My code so far is as follows:

// Get the current context
var context = new SP.ClientContext.get_current(); 
// Get the current site (SPWeb) 
var web = context.get_web(); 
// Get the library 
var list = web.get_lists().getByTitle(ExDocLibName);

//Update some properties of the library
list.set_description('Updated Library description')
list.set_title(NewDocLibName)
list.update();

context.load(list)

// Create callback handlers
var success = Function.createDelegate(this, this.onSuccess); 
var failure = Function.createDelegate(this, this.onFailure); 

// Execute an async query
context.executeQueryAsync(success,failure);

    }
// Async query succeeded.
function onSuccess(sender, args) {

alert('library details have been updated');

// Refresh the page.
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}

// Async query failed.
function onFailure(sender, args) {
alert(args.get_message());
}

1 Answer 1

1

The URL of SPList object is read only property. And you can't set a new URL to it.

The best option you can have is to delete the existing list and create a new one.

1
  • Not even possible from server side object model, let alone the client side. Mar 19, 2015 at 5:19

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.