How to add a file in Document Set using ECMA script?

Hi,
I want to upload a particular file into Document set using ECMA script.
I can do it easily through C# but unable to achieve the same using ECMA Script.
Any pointers or piece of code will be helpful.
Thanx in advance :)
"The Only Way To Get Smarter Is By Playing A Smarter Opponent"

The following blog post provides a way to create a document set using ECMA:
http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
The following blog post provides a way to upload files into a document set using CSOM:
http://www.c-sharpcorner.com/Blogs/12139/how-to-create-document-set-using-csom-in-sharepoint-2013.aspx
See if you can follow the logic in the CSOM example to apply it to ECMA. Let me know if you have specific problems with it.
Dimitri Ayrapetov (MCSE: SharePoint)

Similar Messages

  • Create document set using ECMA Script

    Hi,
    I want to create a document set in SharePoint 2010 document library where i have already included document set content type.
    Is there any way to create a document set using ECMA Script?? If yes, then please provide the sample code for this...
    Thanks.
    -Prashant

    Hi Prashant,
    Although this post is aimed at SP 2013 and the App model, it should give you the object model references you need to complete your goal:
    http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
    In particular the following function should be of use:
    function CreateDocumentSet() {
    var ctx = new SP.ClientContext("http://yourSharePointSite");
    var parentFolder;
    var newDocSetName = $('#txtGetDocumentSetName').val();
    var docSetContentTypeID = "0x0120D520";
    var web = ctx.get_web();
    var list = web.get_lists().getByTitle('DocSetLibrary');
    ctx.load(list);
    parentFolder = list.get_rootFolder();
    ctx.load(parentFolder);
    var docsetContentType = web.get_contentTypes().getById(docSetContentTypeID);
    ctx.load(docsetContentType);
    ctx.executeQueryAsync(function () {
    var isCreated = SP.DocumentSet.DocumentSet.create(ctx, parentFolder, newDocSetName, docsetContentType.get_id());
    ctx.executeQueryAsync(SuccessHandler('Document Set creation successful'), FailureHandler("Document Set creation failed"));
    }, FailureHandler("Folder loading failed"));
    ctx.add_requestSucceeded(function () {
    $('#txtGetDocumentSetName').val('');
    alert('Request Succeeded');
    ctx.add_requestFailed(function (sender, args) {
    alert('Request failed: ' + args.get_message());
    // Failure Message Handler
    function FailureHandler(message) {
    return function (sender, args) {
    alert(message + ": " + args.get_message());
    // Success Message Handler
    function SuccessHandler(message) {
    return function () {
    alert(message);
    Keith Tuomi | Twitter: @itgroove_keith | Blog:
    http://yalla.itgroove.net
    Please click "Propose As Answer" if a post solves the problem or "Vote As Helpful" if a post has been useful to you.

  • How to add js files to sharepoint page using sharepoint designer

    how to add js files to sharepoint page using sharepoint designer

    Upload the files to your site collection into the site assets library or into the style library, depending on perference.
    Then you can include the JS files either in the master page, page tempalte or using web parts.

  • Unable to add aspx file to document library using REST and JSOM in SharePoint Hosted App

    Hi,
    I am unable to add an aspx file to document library.  I was actually trying to create a WIKI page and upload to Pages library but that wasn't working so I tried simple document library.  It keeps failing with Access Denied error.  I have checked
    the blocked types and aspx is not included.  I can upload it directly from the browser so that shouldn't be the case.  I have read that it can be achieved with CSOM but I need this to work with a SharePoint Hosted App.  Here is my JSOM:
    factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
        context.set_webRequestExecutorFactory(factory);
        appContextSite = new SP.AppContextSite(context, hostweburl);
        oWeb = appContextSite.get_web();
        oList = oWeb.get_lists().getByTitle('Documents');
        fileCreateInfo = new SP.FileCreationInformation();
        fileCreateInfo.set_url("mywiki.aspx");
        fileCreateInfo.set_content(new SP.Base64EncodedByteArray());
        fileContent = "<%@ Page Inherits=\"Microsoft.SharePoint.Publishing.TemplateRedirectionPage,Microsoft.SharePoint.Publishing,Version=15.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c\" %> <%@ Reference VirtualPath=\"~TemplatePageUrl\"
    %> <%@ Reference VirtualPath=\"~masterurl/custom.master\" %>";
        for (var i = 0; i < fileContent.length; i++) {
            fileCreateInfo.get_content().append(fileContent.charCodeAt(i));
        newFile = oList.get_rootFolder().get_files().add(fileCreateInfo);
        context.load(newFile);
        context.executeQueryAsync(function () {
            alert('yo');
        }, function (sender, args) {
            alert(args.get_message() + '\n' + args.get_stackTrace());
    If I change the file extension to "txt", it works.  Same with REST implementation, it works with "txt" but fails with "aspx".  Maybe what I am trying to do will not work using JSOM or REST.  Any suggestions?  Your
    help is always appreciated.
    Regards,
    kashif

    Your code works fine in both my on-premises and SharePoint Online. I have given the app full control, so I suspect this is a permissions issue. I would check your permissions on your appmanifest. Must be something to do with publishing permissions. Try
    giving full control and work the permissions down.
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • How to add data in datatable by popup using java script?

    Hi
    I have a datatable in my jsp page. Onclick of button i am opening a popup window. On the popup window I am haveing list of data. I want to select data by checking the checkbox and the selected data need to be populated on the datatable. I am not getting any clue to proceed.
    Can anyone suggest me any solution for this. Its very urgent.
    Regards
    Rishab.

    The following article might provide new insights: [Using datatables|http://balusc.blogspot.com/2006/06/using-datatables.html]. Checkout the chapter titled "Select multiple rows". Make use of this knowledge to select specific rows in the popup and gather them all in the bean.
    Additional note: don't use Javascript to read/add/save data. It's pointless. Only use JS to open the popup window pointing to a JSF page with the datatable inside.
    Edited by: BalusC on 14-mei-2008 16:36

  • How to add a record in document library without upload file.

    Hi,
    how to add a record in document library without upload file?
    Is it possible? I want to create a folders in Document Library but inside folders i do not want to upload a file instead of just i want to create a record. I will map my local file path to the records.
    Can anyone help me on it?
    Thanks & Regards
    Poomani Sankaran

    Hello Sankaran,
    document library is to upload documents, without document you will not be able to add a record or Item to it.
    for your requirement you can use a list and enable folders within the list and maintain the local path of the file as an item in list.
    http://www.sharepointbriefing.com/spconfig/article.php/3834951/Enable-the-New-Folder-Creation-Option-in-SharePoint-Custom-Lists.htm
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful

  • How to add a file to an existing package programmatically in Acrobat 8?

    Hello
    Is it possible to add a file to an existing package programmatically in Acrobat 8? (embed a pdf file in a pdf package programmatically); If so, how should I do it?
    Thanks in advance,

    Finally, I found out how to add a file to an existing package programmatically by using JavaScript (function: app.execMenuItem("AddFileAttachment")). Thanks for your help Ironsenth. However, I need to specify the file to attach programmatically and I can't figure out how to do it.
    Could you let me know where I can find this information (what document to read)? Is there any parameters for the 'AddFileAttachment' method?
    Thanks in advance,

  • Move Files from one document set to another document set using workflow

    Hi All,
    Env : SP 2013 Server - SPD 2013.
    I'm trying to make a SPD Workflow that must copy a  files from one Document Set to another Document set in the same library other document library  
    Does Someone already get success for Copy  files from one Document Set to another Document set?
    Thanks for your help.

    Hi,
    According to your post, my understanding is that you wanted to move Files from one document set to another document set using workflow.
    I recommend to use the custom workflow activity  Copy List Item Extended Activityto
    copy files to another document set.
    You can do this with codeless SharePoint Designer workflows as long as you can install the
    Codeplex Custom SharePoint Designer Workflow Activities. 
    These activities are also built-in to SPD2013. However, you can only use the custom activities in the SharePoint 2010 Platform.
    To install the custom activities, please follow the steps as below:
    Download the solution file form
    Useful Sharepoint Designer Custom Workflow Activities
    Copy the wps file to the Disk C.
    Open the SharePoint 2013 Management Shell.
    Run the command: add spsolution c:\ dp.sharepoint.workflow.wsp
    Open the Center Administration, click System Setting->Manage Farm Solution-> dp.sharepoint.workflow.wsp->Deploy to one or more Web Application.
    Open the SharePoint designer, create SharePoint 2010      Platform workflow, add action from Custom Actions.
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to add PDF files into a slides? (Flash 8)

    I am new to flash and I am using Macromedia Flash 8. My task is simple enough: I need create a Presentation with Screens from PDF files: I have 10-12 PDF files which I want convert into flash presentation.
    I have read this tutorial:
    http://w3.id.tue.nl/fileadmin/id/objects/E-Atelier/Phidgets/Software/Flash/fl8_tutorials.p df
    Chapter 11: Basic Tasks: Create a Presentation with Screens.
    I'm having trouble how to add PDF files into a slides: I want insert a whole pdf file as separate slide, without splitting pdf file into separate elements: pictures, text, etc. I tried import pdf file into Flash, wheen import there is shown prompt how program should process this pdf file(add in stage, library, as keyframes, etc) , not clear which option is correct for my task. What I got is pdf file splitted into multiple images, text, - which is not what I want. I want keep PDF files without changes, preserve original design and formatting, just convert this pdf into flash, so presentation will consist of PDFs organized in correct order, then add navigation buttons and some effects. How to solve this task?

    Just to avoid potential confusion... PDF is an Adobe format, but Flash 8 is/was not.  Flash 8 came out before Adobe bought Macromedia.  Even today, I don't believe anything has been done to accomodate direct integration of PDF content in Flash.

  • How to update managed metadata column for all file in document library using powershell

    Hi,
    How to update managed metadata column for all file in document library using powershell?
    Any help on it.
    Thanks & REgards
    Poomani Sankaran

    Hi TanPart,
    I have changed the code which you have give in order to get the files from SharePoint 2010 Foundation  Document Library.But i am getting below error in powershell.
    Property 'ListItemCollectionPosition' cannot be found on this object; make sure it exists and is settable.
    Could you tell me which is the issues in it?
    See the code below.
    $web = Get-SPWeb http://ntmoss2010:9090/Site
    $list = $web.Lists["DocLib"]
    $query = New-Object Microsoft.SharePoint.SPQuery
    $query.ViewAttributes = "Scope='Recursive'";
    $query.RowLimit = 2000
    $caml = '<Where><Contains><FieldRef Name="Title" /><Value Type="Text">Process Documents/Delivery</Value></Contains></Where>' +
            '<OrderBy Override="TRUE"><FieldRef Name="ID"/></OrderBy>'
    $query.Query = $caml
    do
        $listItems = $list.GetItems($query)
        $spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
        foreach($item in $listItems)
            #Cast to SPListItem to avoid ambiguous overload error
            $spItem = [Microsoft.SharePoint.SPListItem]$item;
            Write-Host $spItem.Title       
    while ($spQuery.ListItemCollectionPosition -ne $null)
    Thanks & Regards
    Poomani Sankaran

  • How to add ndf files in alwaysOn ?

    HI All,
    How to add ndf files in alwayson (database added in ag group).
    Thank
    Vijay

    As per me:In Always ON you can add the data without breaking by alter database statement the file path (including the drive letter) of a given secondary database be identical to the path of the corresponding primary database.
    In case drive letter is different, follow steps mentioned in below link:
    http://technet.microsoft.com/en-us/library/hh510190.aspx
    Please click the Mark as answer button and vote as helpful if this reply solves your problem

  • How to add .m4r files from my computer to my tones in iPhone 6 iOS 8.1.1 ?

    How to add .m4r files from my computer to my tones in iPhone 6 iOS 8.1.1 ?

    You've sycned other content via your computer's iTunes to the phone ?
    You can sync photos to your phone via your computer's iTunes : connect your phone to your computer, click on its icon towards the top left of the iTunes screen, and select Photos on the left-hand side of the screen :
    Photos that you sync from a computer can't be deleted directly in the phone's Photos app, instead they are deleted by not including them in the next photo sync - so you will need to include all photos that you want from your computer in each photo sync.

  • How do add .mov files in Premiere Elements 11 with Windows 8? I get a generic error message.

    How do add .mov files in Premiere Elements 11 with Windows 8? I get a generic error message.

    Hi Steve,
    Thanks for your quick response. The original movies were taken on a Canon ES970 (1990's). I don't know the resolution but things were not as high tech back then.,.. I used a Roxio software to convert them on my MacBook Air. I didn't realize that I could use Adobe Premiere Elements to do that or I would have. However my old camera did not have a cable to attach it to a computer and the Roxio software came with it.
    I then saved the recordings on an external hard drive. I did not make movies from them using iMovie or edit them in any way. They are simply .MOV files and they can be played on my Mac. Upon realizing how much memory it takes to work on videos, I decided it might be easier to burn DVD's on my husband's  new Dell desktop that came with Windows 8. I downloaded Quicktime as suggested and still the movies can't be added to Premiere.

  • I forget how to add audio to a document I have made.

    I forget how to add audio to a document I have made.

    lola2610 wrote:
    I can duplicate but that is not what I am looking for.
    This is what it is for. Save As doesn't change the behaviour of Autosave. All changes always get saved at all times. If you want to save as a new document, then do that. If you want to do a save as, just don't make any changes beforehand.
    Second problem is the load of internet pages! It is sooooo slow...
    Try a new DNS server such as OpenDNS. The ones your ISP gives you can be very bad.

  • How to add audio files.

    I'm using Premiere Elements 11 on my iMac.  I can't for the life of me figure out how to add music files to the 8 or so that come with the program.  Anybody else having this problem or am I just dumber than most?

    Comstar 11 wrote:
    As I put in my original post I might be dumber than most and that's still a possibility.  I also tried the "Use Smartsound" same feeling that I didn't like the add on that just took me to another site to sell me music.  I couldn't find the "Project Assets" box after looking almost everywhere.  But.....  I was in the "Quick" mode.  Knowing I was a rank beginner I avoided the "Expert" tab.  But after looking everywhere else I opened that tab and "It's A Miracle" there it was.  Still stumbling through the learning process so thanks for your kind help.  If I hit the wall again I'll make another post looking for help.  Thanks Again.
    I tried the Quick mode.  When I did 'add media' in the upper left corner, video files went straigt to the project box.  Then I tried an audio file and it went below the video in the project box.  So, I see where in 'Quick' the 'Project Assets' box and step are skipped.  Sorry about misleading you.
    Either way, audio files get to the project box when you pick them up as a file on your computer.
    There are two great sources to speed the learning process.  lynda.com has courses that are like a personal demo of everything PrE does with a great coach explaining it.   http://www.lynda.com/Premiere-Elements-tutorials/Up-Running-Premiere-Elements-11/109763-2. html  A few if the chapters are free as a trial.  The fee is $25 for a month of access.  One month is more than enough if all you want is the one course. 
    If you prefere owning a course on a disk, video2brain is an alternative, but I don't think it is as thorough.
    Bill
    Bill

Maybe you are looking for

  • RESTORE 'NUMBER OF ITEMS' AND 'SPACE AVAILABLE' IN OPEN WINDOW

    something we seem to have lost in LION is the useful number of items and memory avail or used at the bottom of windows/drive windows. any way to restore?

  • How to Print Sales header text at the end of last page of Main Window

    Dear All, I have a requirement to print Sales order header text at the end of Main of last page. I don't have footer window.When i use Bottom-End bottom.Only one line is printing.The header has 5 lines. Request you to provide <b>code</b>to handle thi

  • IPhone not updating due to lack of iTunes and Mac OSX update

    Hello, I have an iPhone 3GS running software version 4.1 and am needing to update it to the next version. When I click on the 'update' button when the phone is connected to my MacBook, a window pops up that says 'This version of iTunes (9.2.1) is the

  • Combo value

    I am performing validation on the A/R invoice.I have considered transaction category and form no from the tab tax.If the value in the form no. is FORM 'C' or FORM 'H' or FORM 'I' or CONCESSIONAL FORM or DEXPORT then Sales should be transaction catego

  • I need to add a device to my account

    Please help how do I add another device to my Find My Iphone App?