Listing Document Libraries using JavaScript

Is it possible to use JavaScript to list all document libraries of a site? I would like to create a page that lists all document libraries (where the document library's name meets certain criteria).
Johan Raeymaeckers

You can use the Object Model to do this.  MS have authored an article that explains it better than I can here.  It has quite a few interesting other tricks too.
http://msdn.microsoft.com/en-us/library/hh185009
Steven Andrews
SharePoint Business Analyst: LiveNation Entertainment
Blog: baron72.wordpress.com
Twitter: Follow @backpackerd00d
My Wiki Articles:
CodePlex Corner Series
Please remember to mark your question as "answered" if this solves (or helps) your problem.

Similar Messages

  • How to rename content type on web site level and underneath all the document libraries using powershell?

    Hello
    I wantto rename content type on web site level and underneath all the document libraries using powershell, please let me know how can do this?
    I saw this url
    http://suryapulipati.blogspot.in/2011/08/rename-content-type-name-in-list-using.html, but I want to change everything from Web Site, subsite and underneath document libraries. Because if you try to change on any on document library, it will be applicable
    for that document library, if you change on web level then underneath document libraries content type names not updated automatically.
    Please advise
    Avi

    Not sure with powershell.
    I could help you out with Server Side or Web Services though.
    Brandon James SharePoint Developer/Administrator

  • Allowing only pdf files in document library using Javascript

    HI,
    I have a document library in sharepoint 2013, where i want only pdf files to get uploaded in it. I have created event receiver for the same and it is working fine. but i want to restrict the files using javascript on
    the page itself, since, In event receiver, after the file is getting uploaded, it is checking and throwing error. So, is there any way to check for the file type before uploading the file and show error message if wrong file is uploaded?
    Harikrishna Baskaran

    Bind event to the upload button and add jquery to validate the file extension. Refer to the following posts for more information
    http://stackoverflow.com/questions/13124950/change-onclick-event-input-type-button-in-ie-8-9-ff-with-jquery-won%C2%B4t-wo
    http://stackoverflow.com/questions/4234589/validation-of-file-extension-before-uploading-file
    --Cheers

  • Copy Attachments of sharepoint list item to a document library using Javascript on click of a button

    The requirement is as follows:
    1. We have a SP list. All items in the list have mulitple attachments.
    2. On click of a button, All the attachments of all items should be copied to a document library
    This is to be done from client side only. No server code is acceptable. We have tried following things:
    1. USing Asynch call
    context = new SP.ClientContext("my site name");
             this.oWebsite = context.get_web();
             var lists = oWebsite.get_lists();
             var list = lists.getByTitle('my list name');         
             context.load(oWebsite);
             var folderPath = 'Lists/<my list name>/Attachments/' + folderId;
             var Folder = oWebsite.getFolderByServerRelativeUrl(folderPath);
             context.load(Folder);
             Files = Folder.get_files();
             context.load(Files);
             context.executeQueryAsync(Function.createDelegate(this, this.ExecuteCopyOnSuccess), Function.createDelegate(this, this.ExecuteCopyOnFailure));
    function ExecuteCopyOnSuccess(sender, args) {        
             for(var p=0;p<this.Files.get_count();p++)
         var file = Files.itemAt(p);    
              var filename = file.get_name();      
              if (filename != null) {
                  var newUrl = 'document library url';
                  file.copyTo(newUrl, true);
                  context.executeQueryAsync(null,null);
    In this case, Files.get_count() throws error - The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
    2. Using copy.asmx service
    It copies files to document library but some files are blank and are having size 0.
    Thanks!

    Hi,
    I think you can use Document Content types or document sets -
    Here are links that you can refer to
    http://office.microsoft.com/en-us/windows-sharepoint-services-help/introduction-to-content-types-HA010121570.aspx
    http://msdn.microsoft.com/en-us/library/office/ms472236(v=office.14).aspx
    http://office.microsoft.com/en-us/sharepoint-server-help/create-and-configure-a-new-document-set-content-type-HA101782461.aspx
    http://office.microsoft.com/en-us/sharepoint-server-help/introduction-to-document-sets-HA101782466.aspx?CTT=5&origin=HA101782461
    Hope this helps!
    MCITP: SharePoint 2010 Administrator
    MCTS - MOSS 2007 Configuring, .NET 2.0
    | SharePoint Architect | Evangelist |
    http://www.sharepointdeveloper.in/
    http://ramakrishnaraja.blogspot.com/

  • I need a list of libraries used in C# Windows Forms technology.

    Windows Forms is a technology to make apps for Windows.
    It uses only a part of .Net Framework.
    I need a list of what it uses.
    I am talking about Windows Forms technology, not Windows.Forms namespace.
    I don't need .Net Framework Class Library, i need only what Windows Forms uses.
    Thank you.

    > here are a few other namespaces that Windows Forms relies on
    It is not a few, there are lots of those it relies on.
    I need a list of namespaces that it relies on.
    I repeat, i open a new Windows Forms project, i should know names of references to add them, right?
    It uses a part of .Net Framework, and it doesn't use only System.Windows.Forms namespace, it uses others
    too.
    I repeat, i must know names of references to add them.
    How can i do it?
    It is a simple question.

  • Create a document based on specific document template using JavaScript (ECMA Script/REST API/SP Services)

    Hi,
    I have requirement to create a new document based on specific document template available in document library. Able to set the specific content type but the respective document template not being applied. I am trying with ECMAScript, REST API and SPServices
    but no luck for now. Please help me.
    Thanks,
    JP

    Hello,
    I have already tried your solution, however in that case I get the error - "UncaughtSys.ArgumentNullException: Sys.ArgumentNullException:
    Value cannot be null.Parameter name: context"...
    Also, I tried removing SP.SOD.executeFunc
    from my code, but no success :(
    Kindly suggest !!!
    Vipul Jain

  • Unable to add items to dropdown list using javascript

    Hi,
    I'm trying to add additional items to a dropdown list at runtime using javascript.
    I'm doing this by invoking the addItem method on the dropdown list field during its initialize event.
    However when I run the generated pdf in Acrobat Pro, I get the following error in the console -
    GeneralError: Operation failed.
    XFAObject.addItem:3:XFA:form1[0]:#subform[0]:field0[0]:initialize
    Method: 'addItem' cannot be called because doing so would violate this document's permissions settings.
    The pdf form has no signatures or any other stuff in it.
    What additional permissions do I need to add and how ?
    You can view the pdf here -
    https://dl.dropboxusercontent.com/u/8022836/xfa3_test.pdf
    Thanks,
    Joel

    Is there a reason to use the code you did? It looks like the problem is with the variable's permissions when going through the template.
    This code works just fine in that same event:
    this.addItem("new item");
    As does:
    var f = xfa.resolveNode("form1.#subform1[0].field0");
    f.additem("new item");

  • How to upload a document with values related to document properties in to document set at same time using Javascript object model

    Hi,
          Problem Description: Need to upload a document with values related to document properties using custom form in to document set using JavaScript Object Model.
        Kindly let me know any solutions.
    Thanks
    Razvi444

    The following code shows how to use REST/Ajax to upload a document to a document set.
    function uploadToDocumentSet(filename, content) {
    appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var restSource = appweburl +
    "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('/restdocuments/testds')/files/add(url='" + filename + "',overwrite=true)?@target='" + hostweburl + "'";
    var dfd = $.Deferred();
    $.ajax(
    'url': restSource,
    'method': 'POST',
    'data': content,
    processData: false,
    timeout:1000000,
    'headers': {
    'accept': 'application/json;odata=verbose',
    'X-RequestDigest': $('#__REQUESTDIGEST').val(),
    "content-length": content.byteLength
    'success': function (data) {
    var d = data;
    dfd.resolve(d);
    'error': function (err,textStatus,errorThrown) {
    dfd.reject(err);
    return dfd;
    Then when this code returns you can use the following to update the metadata of the new document.
    function updateMetadataNoVersion(fileUrl) {
    appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var restSource = appweburl +
    "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('/restdocuments/testds')/files/getbyurl(url='" + fileUrl + "')/listitemallfields/validateupdatelistitem?@target='" + hostweburl + "'";
    var dfd = $.Deferred();
    $.ajax(
    'url': restSource,
    'method': 'POST',
    'data': JSON.stringify({
    'formValues': [
    '__metadata': { 'type': 'SP.ListItemFormUpdateValue' },
    'FieldName': 'Title',
    'FieldValue': 'My Title2'
    'bNewDocumentUpdate': true,
    'checkInComment': ''
    'headers': {
    'accept': 'application/json;odata=verbose',
    'content-type': 'application/json;odata=verbose',
    'X-RequestDigest': $('#__REQUESTDIGEST').val()
    'success': function (data) {
    var d = data;
    dfd.resolve(d);
    'error': function (err) {
    dfd.reject(err);
    return dfd;
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • How I can use Visual Studio 2013 to create lists or libraries via remote?

    Hello guys,
    I use visual studio on my machine and try to create a list, but the sharepoint server is on another machine. It is possible to run a program on my computer and then create a list on the sharepoint server. If yes, how can I achieve this?
    Best regards
    Matthias

    You can create and manage lists and libraries using SharePoint Designer. To use Visual Studio you would have to create a SharePoint project, create a feature, define the list, etc. then create a Solution package and deploy that to the server. If you just
    want to manually add a list then use Designer.
    Mike Smith TechTrainingNotes.blogspot.com
    Books:
    SharePoint 2007 2010 Customization for the Site Owner,
    SharePoint 2010 Security for the Site Owner

  • Problem using javascript to submit jsf form, values not submitted

    Greetings!
    I have a t:selectOneMenu where I want the page to be submitted when they change the selected value. At this point, I am able to get the form to submit and reload the page, which is all fine. The problem is that none of the values from the page are not set in the backing bean. I have break points on the setter methods that are not being hit.
    I have tried a number of things from searching multiple forums, but here are snippets from my latest version...
    <h:form>
    <t:commandLink id="hiddenLink" forceId="true" value="test link"
    action="#{pc_PageX.doBtnHiddenLinkAction}"></t:commandLink>
    <t:selectOneMenu id="pageList_top" forceId="true" value="#{pc_PageX.ValueX}"
         onchange="jspellSync(); submitPageX();">
         <f:selectItems value="#{pc_PageX.ListX}" />
    </t:selectOneMenu>
    </h:form>
    function submitPageX(){
         var hiddenLink = document.getElementById("hiddenLink");
         hiddenLink.click();
    }Note that the <t:commandLink> is not hidden, though it will be in the final version if I can get this to work.
    If I click the commandLink myself, the page is submitted with all the page values as expected. If I change the list value, thus using javascript to fire the commandLink's click event, the page is submitted with NO values.
    Can anyone come up with an explanation for this behavior? Or better yet, a solution?
    A couple other things I've tried...
    - Not using a commandLink and using jsf's submit function -> onchange="jspellSync(); submit();"
    - Clicking the link using other ways -> hiddenLink.fireEvent('onclick');
    If all else fails, I'll just add a button that they have to click to submit the form.

    snotmare wrote:
    BalusC wrote:
    I recall this problem in one of the ancient JSF versions. Which JSF version do you use? Do you have any room to upgrade to latest? We're using an IBM implementation of JSF, which is at version 7.0. The IBM implementation appears to be built on the JSF base 1.1.That's not an IBM JSF implementation, they do not have any one, they just have some component libraries which runs on top of some JSF implementation. RAD/WSAD ships by default with Sun JSF RI. Try upgrading to at least 1.1_02 which you can download from the aforementioned link. There's a gap of 2 years (and inherently a lot of bugfixes) compared to 1.1. If the application server used supports Servlet 2.5, you could even upgrade to the latest 1.2.
    We've had other issues with the IBM implementation, which could be the cause in this case too. We've been talking about switching to MyFaces, but there is one feature of the IBM version that we like. It's basically a script collector (hx:scriptCollector) that allows us to do pre-processing on the page.As said before, IBM does not have a JSF implementation. So replacing RI by MyFaces wouldn't make any difference.

  • Document Set Creation in document library using REST API in Sharepoint 2013

    Hi,
    I want to create the document set using REST API call. Currently i am able to create the folder and able to upload the files using REST API's in the document library. Is there any way we can pass the contentype name or Id and create the document set using
    REST API call. We need to create the document set along with metadata and upload the files inside the document set.
    I need to create the document set along with meta data column values using REST API. Please let me know how we can achieve this through REST API.
    Thank you,
    Mylsamy

    Hi,
    According to your post, my understanding is that you wanted to create document set along with managed metadata fields.
    The REST API does not currently support working with Managed Metadata or Taxonomy fields.
    As a workaround, we can use the JavaScript Client Object Model.
    Create document set using JavaScript Client Object Model.
    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
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/aacd96dc-0fb2-4f0d-ab4c-f94ce819e3ed/create-document-sets-with-javascript-com-sharepoint-2010
    Set managed metadata field with JavaScript Client Object Model.
    http://sharepoint.stackexchange.com/questions/95933/add-list-item-with-managed-metadata-field-through-jsom
    http://sharepointfieldnotes.blogspot.com/2013/06/sharepoint-2013-code-tips-setting.html
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • Users are unable to synchronize document libraries with OneDrive for Business

    Hello,
    We are having an issue with our users attempting to synchronize document libraries with OneDrive for Business. When a user tried to synchronize the document library either via the "SYNC" button on the document library page using IE or by
    manually entering the document libraries path into the OneDrive for Business desktop app they receive the following error
    "We can't connect to the specified SharePoint site". The users have the Edit permission to both the site and the document library. I have performed the following actions in attempt to get the synchronization to work.
    1. Tested giving user the owner permission to the site and document library. same result.
    2. Performed a repair on the users Office 2013 installation.
    An interesting point to note is that I myself am able to synchronize the document libraries using both the "SYNC" button on the document library site and by entering the path manually in the desktop app. Difference between my account and the test
    accounts is that I'm a site collection administrator and farm administrator. Can anyone shed some light onto this issue?

    Hi Corey,
    According to your description, my understanding is that the users cannot sync document libraries with OneDrive for Business.
    I recommend to check the Permission Level to see if the Use Client Integration Features permission is selected.
    If not, check this permission in the corresponding permission level which is granted to the users.
    Please also check if the users have the right permission to sync the document library with OneDrive for Business.
    More reference:
    http://nheylen.wordpress.com/2014/05/15/sync-error-we-cant-connect-to-the-specified-sharepoint-site/
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Connect document libraries via connections

    Hi,
    I need to connect two (or more) document libraries using 'Connections'.
    I created a new page.
    Added 2 document libraries.
    I want the user to be able select a customerid in document library 1 (Customer)
    I want to use the customerid selected in document library 1 as a filter for document library 2 (customer details).
    Problem: I do not see the connections option on a document library.
    Any ideas?
    Thnx!
    I want to the following for document libraries:
    http://www.youtube.com/watch?v=HR6WolyHv2Q

    Hi,
    Which permission did you use? I had check again with only edit permission, the connections option worked well.
    Did you check with other pages? You can create a new page, then check whether it works.
    Did you use the compatibility mode or add the site into trusted sites?
    You can use compatibility mode to check whether it works.
    Open IE->Tools->Compatibility View Settings
    You can also add the site into Trusted sites.
    Open the IE->Internet Options->Security->Sites->add the site into the Websites, then check whether it works.
    What's more, you can use other browsers to check whether it works, such as Firefox, Chrome.
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Data View Web Part - List of Subsites and Document Libraries under Current Site - Must be able to Package as Site Template in SPDesigner

    Hi Guys,
    On the home page of each sub site I would like to be able to show a list of subsites and Document libraries that are under the current subsite.
    I started investigating a solution using Datasources with SOAP requests sent to the server but it is very difficult to understand how to surface it on the Data View WebPart.
    I have tried with the search results webpart but the problem is that it does not work well when packaged in a Site Template.
    Please advise.
    Thanks and Regards,
    Rhyan

    Ok,
    Here is the problem:
    When creating a mysite from powershell or script, apparently you can ONLY do this from a wfe (or a server running Microsoft SharePoint Foundation Web Application in services on server).
    You CANNOT create mysites from script on your appserver if it is not also a Web Application Server. I confirmed the same is true in my test farm. I guess I was always running most of these scripts on the webserver.
    I searched all over and cannot find this documented anywhere.
    Who do I contact to have Microsoft document this?
    It's Thursday morning, I've been working non stop since Saturday morning so you don't have to :)

  • SharePoint 2013 - document libraries and newsfeeds are visible when viewed using Internet Explorer running on the server but not from any other machine

    On a single Windows 2012 R2 server I have installed SQL 2012 and SharePoint 2013 SP1 with the latest update roll ups. When I remote desktop to the server using the farm and site collection admin account  and open page http://server_name_here using
    Internet Explorer, I'm able to see newsfeeds and document libraries.
    If I connected to a separate Windows 7 machine as  the farm and site collection admin account  and open page http://server_name_here using Internet Explorer, I'm able to view the SharePoint pages except I cannot see any newsfeeds or document libraries.
    There's just blank space where they should be. I have repeated this process on several other machines that are not the server and get the same result on every machine (I've tried other servers, desktops, adding the SharePoint site to the trusted sites list
    in IE, even using firefox). I'm using the same account as I did when I logged onto the server directly. Any thoughts as to what's going on?
    Thanks!

    Thanks for the idea, Harsh. What am I looking for?
    It is currently set to the default of http://server_name and http://server_name:port_number (the latter is for Central Admin).
    When I have access to the server, I have always done so the same way, using http://server_name. This was true when I access it from the desktop of the server itself and when I tried to access it from other desktops and servers (the machines where I had the
    issues with the libraries and feeds not showing up). Are there other values I should add?
    I have not tried to add http://server_FQDN as we don't plan on using that to access it but if you think it will help I would be happy to add it.

Maybe you are looking for

  • Migration between one VM to another VM

    This is a problem that has come across my work environment.  We have a Hyper-V VM Server 2012 R2 as our terminal server, and it is crashing periodically 2-3 times a day.  The Host server is fine however, but the cause i learned through the dmp files

  • 24" display/Graphic card

    Would an ATI 9000 Pro (64 MB) and a GEForce4 MX (32 MB) be able to handle a 24" LCD?

  • Compoze Groupware integration in WSRP

    Hi, Compoze Groupware integration in WSRP. 1) Created a producer with compoze Group ware portlet. (Compoze_Groupware) with Registration Mandatory 2) Created a Consumer portlet in another domain using Producers wsdl file. 3) Added a Weblogic login por

  • Z3v is very slow at searching in apps while connected to Wi-Fi. Is there any way to fix?

    I recently received the Z3v as a gift this Christmas and it seems that there is an issue with the Wi-Fi because when I try to search Google Play or use any app that uses my Wi-Fi such as Hulu or Wikipedia it takes forever to load but if I connect usi

  • Escalation of unanswered requests in workflow

    Hello friends, As I can add a timer to a workflow that can be scaled if the request is not met in a given time. This on an environment of Oracle Identity Manager 9.1.0.2 thanks