Skip to main content

Adding folder to Document Set problematicallyprogrammatically JSOM SharePoint 2013

added 87 characters in body
Source Link
Maddy
  • 199
  • 1
  • 16

I am trying to add a folder to the document set but the folder got created at the parent document library. Can somebody help me to find out what am i doing wrong ?

Following is the code:

var createFolder = function(context, list, foldername) {
        var itemCreateInfo = new SP.ListItemCreationInformation();
        itemCreateInfo.set_underlyingObjectType(SP.FileSystemObjectType.folder);
        itemCreateInfo.set_leafName(foldername);
        itemCreateInfo.set_folderUrl = String.format("/Lists/{0}/{1}", "Documents", "Custom");
        var listItem = list.addItem(itemCreateInfo);
        listItem.set_item('Title', foldername);
        listItem.update();
        context.load(listItem);
        context.load(list);
        context.executeQueryAsync(
            Function.createDelegate(this, successHandler()),
            Function.createDelegate(this, errorHandler));

        function successHandler() { console.log('Success'); }

        function errorHandler() { alert("Request failed: message = " + arguments[1].get_message()); }
    }

"Documents" is the document library and "Custom" is the document set in above code.

Thanks.

I am trying to add a folder to the document set but the folder got created at the parent document library. Can somebody help me to find out what am i doing wrong ?

Following is the code:

var createFolder = function(context, list, foldername) {
        var itemCreateInfo = new SP.ListItemCreationInformation();
        itemCreateInfo.set_underlyingObjectType(SP.FileSystemObjectType.folder);
        itemCreateInfo.set_leafName(foldername);
        itemCreateInfo.set_folderUrl = String.format("/Lists/{0}/{1}", "Documents", "Custom");
        var listItem = list.addItem(itemCreateInfo);
        listItem.set_item('Title', foldername);
        listItem.update();
        context.load(listItem);
        context.load(list);
        context.executeQueryAsync(
            Function.createDelegate(this, successHandler()),
            Function.createDelegate(this, errorHandler));

        function successHandler() { console.log('Success'); }

        function errorHandler() { alert("Request failed: message = " + arguments[1].get_message()); }
    }

Thanks.

I am trying to add a folder to the document set but the folder got created at the parent document library. Can somebody help me to find out what am i doing wrong ?

Following is the code:

var createFolder = function(context, list, foldername) {
        var itemCreateInfo = new SP.ListItemCreationInformation();
        itemCreateInfo.set_underlyingObjectType(SP.FileSystemObjectType.folder);
        itemCreateInfo.set_leafName(foldername);
        itemCreateInfo.set_folderUrl = String.format("/Lists/{0}/{1}", "Documents", "Custom");
        var listItem = list.addItem(itemCreateInfo);
        listItem.set_item('Title', foldername);
        listItem.update();
        context.load(listItem);
        context.load(list);
        context.executeQueryAsync(
            Function.createDelegate(this, successHandler()),
            Function.createDelegate(this, errorHandler));

        function successHandler() { console.log('Success'); }

        function errorHandler() { alert("Request failed: message = " + arguments[1].get_message()); }
    }

"Documents" is the document library and "Custom" is the document set in above code.

Thanks.

Source Link
Maddy
  • 199
  • 1
  • 16

Adding folder to Document Set problematically JSOM SharePoint 2013

I am trying to add a folder to the document set but the folder got created at the parent document library. Can somebody help me to find out what am i doing wrong ?

Following is the code:

var createFolder = function(context, list, foldername) {
        var itemCreateInfo = new SP.ListItemCreationInformation();
        itemCreateInfo.set_underlyingObjectType(SP.FileSystemObjectType.folder);
        itemCreateInfo.set_leafName(foldername);
        itemCreateInfo.set_folderUrl = String.format("/Lists/{0}/{1}", "Documents", "Custom");
        var listItem = list.addItem(itemCreateInfo);
        listItem.set_item('Title', foldername);
        listItem.update();
        context.load(listItem);
        context.load(list);
        context.executeQueryAsync(
            Function.createDelegate(this, successHandler()),
            Function.createDelegate(this, errorHandler));

        function successHandler() { console.log('Success'); }

        function errorHandler() { alert("Request failed: message = " + arguments[1].get_message()); }
    }

Thanks.