6

I am trying to rename a folder inside a Document library. Right now I get my item and everything is good but when I try to rename it using set_item('title', 'NewFolderName') it crashes and unwinds the stack.

Is there some kind of documentation that would help us with that? Should I be doing this on the backend instead of the frontend?

Working

context = SP.ClientContext.get_current(); 
var iter = folderList.getEnumerator();
iter.moveNext();

var folder = iter.get_current();

folder.set_item('Title', 'TestTitleRename');
folder.set_item('FileLeafRef', 'TestTitleRename');
folder.update();
context.executeQueryAsync(Success,Failure);

Thanks

  • 1
    Have you not only set the "Title" but also the "FileLeafRef" (to the same value as the Title)? – marco Apr 13 '12 at 19:41
  • What exactly is the error you are getting? Can you post your code here? See the following link on updating a listitem. (The folder is also a list item ultimately) msdn.microsoft.com/en-us/library/hh185011.aspx – Vardhaman Deshpande Apr 13 '12 at 19:43
  • Yes i was missing FileLeafRef, post as answer and ill mark yours. Thanks :D – Dr.Denis McCracleJizz Apr 13 '12 at 20:23
5

As I commented already: ;-)

You have to set not only the "Title" but also the "FileLeafRef".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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