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?

2

1 Answer 1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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