1

I am creating Hidden document library using SharePoint hosted App and i have to hide this hidden library from quick launch.

I used below code but it's not working.

function createDocumentLibrary() {
    clientContext = new SP.ClientContext.get_current();
    hostcontext = new SP.AppContextSite(clientContext, hostweburl);
    this.web = hostcontext.get_web();
    this.lists = this.web.get_lists();
    clientContext.load(this.lists);
    clientContext.executeQueryAsync(Function.createDelegate(this, createDocumentLibrarySuccess), Function.createDelegate(this, createDocumentLibraryFail));
}
function createDocumentLibrarySuccess() {
    var listCreationInfo = new SP.ListCreationInformation();
    listCreationInfo.set_title(libraryName);
    listCreationInfo.set_templateType(SP.ListTemplateType.documentLibrary);
    this.oList = this.web.get_lists().add(listCreationInfo);
    this.oList.set_noCrawl(true);
    this.oList.set_hidden(true);
    this.oList.set_onQuickLaunch(false);
    this.oList.update();
    clientContext.load(this.oList, 'RootFolder');
    this.newColumn = this.oList.get_fields().addFieldAsXml("<Field Type=\"Text\" DisplayName=\"JSVersion\" Name=\"JSVersion\" />", true,
        SP.AddFieldOptions.defaultValue);
    clientContext.load(this.newColumn);
    clientContext.executeQueryAsync(Function.createDelegate(this, onDocumentLibraryCreated), Function.createDelegate(this, onDocumentLibraryCreationFailed));
}
function createDocumentLibraryFail(sender, args) {
    console.log("Error : Create Document Library From > createDocumentLibrary. " + args.get_message());
}
function onDocumentLibraryCreated() {
    console.log("onDocumentLibraryCreated: Library Creted");
}
function onDocumentLibraryCreationFailed(sender, args) {
    console.log("Error : Create Document Library From > createDocumentLibrarySuccess. " + args.get_message());
}

How can i achieve solution?

1

Your code works fine on my site. But you can try this after listCreationInfo.set_templateType

listCreationInfo.set_quickLaunchOption(SP.QuickLaunchOptions.off);

in place of

this.oList.set_onQuickLaunch(false);

Reference link.

  • Thanks for response but not working for me. – Chandani Prajapati Sep 12 at 12:14
  • Is it visible in "recent"?? – harshal gite Sep 12 at 12:15
  • Yes still it is visible – Chandani Prajapati Sep 12 at 12:17
  • You will need to remove recent from the quick launch. – harshal gite Sep 12 at 12:20
  • But my requirement is to only hide that hidden library after creating as i told i am creating hidden library – Chandani Prajapati Sep 12 at 12:23

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.