Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuickLaunchOption = QuickLaunchOptions.Off and list.OnQuickLaunch = false; not working #1488

Closed
1 of 4 tasks
MrTantum opened this issue Mar 19, 2018 · 3 comments
Closed
1 of 4 tasks

Comments

@MrTantum
Copy link

MrTantum commented Mar 19, 2018

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

When creating a list using Client Object Model the parameter QuickLaunchOption = QuickLaunchOptions.Off should not add the new list to the "Recent" section of the quicklaunch as mentioned in the documentation:

"Enumeration whose values specify that the list is not displayed on the Quick Launch of the site. The value = 0."

Furthermore the parameter list.OnQuickLaunch = false; should hide a list from the quicklaunch as mentioned in the documentation:

Gets or sets a value that specifies whether the list appears on the Quick Launch of the site.

The problem exists in SharePoint Online and SharePoint 2016.

Observed Behavior

None of these settings hides the list from the quicklaunch in "recent" section.

Steps to Reproduce

Create a new console application and add the Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime dlls.

Add the following code to the console application and start debugging:

string siteCollectionUrl = "https://...";
using (var context = new ClientContext(siteCollectionUrl))
{
    var web = context.Web;
    context.Load(web,  l => l.QuickLaunchEnabled);
    context.ExecuteQuery();
    Console.WriteLine($"Quicklaunch enabled:{web.QuickLaunchEnabled}");

    var listCreationInfo = new ListCreationInformation
    {
        Title = "QuicklaunchTestList",
        TemplateType = (int)ListTemplateType.GenericList,
        QuickLaunchOption = QuickLaunchOptions.Off
    };
    var list = context.Web.Lists.Add(listCreationInfo);
    context.ExecuteQuery();
    //List is visible still visible in quicklaunch after this line

    list.OnQuickLaunch = false;
    list.Update();
    context.ExecuteQuery();
    //List is visible still visible in quicklaunch after this line
}
@srideshpande
Copy link
Contributor

@MrTantum - Thanks for reporting the issue. When I quickly looked at the code, this behavior seems to be expected. Anything above SP 2013 will keep it open and below that will respect the params which you are passing in.

I am still looking at it and trying to get in touch with the dev who coded it. I will get back to you as and when I receive an update.

Thanks for waiting!

@MrTantum
Copy link
Author

No answer yet therefore I had to find another solution. The following script will delete the new entry from recent after creation of a list:

https://tantumpoint.wordpress.com/2018/03/20/csom-delete-list-from-quicklaunch-recent-node-after-creation/

var listCreationInfo = new ListCreationInformation
{
    Title = "TestList",
    TemplateType = (int)ListTemplateType.GenericList,
    QuickLaunchOption = QuickLaunchOptions.Off
};
list = context.Web.Lists.Add(listCreationInfo);
context.ExecuteQuery();
context.Load(list, l => l.DefaultViewUrl);
context.ExecuteQuery();                
 
//get the node which does not have a url set because the "Recent" node never has an url
var quickLaunchNodeColl = context.Web.Navigation.QuickLaunch.Where(l => l.Url == null || l.Url == string.Empty).Include(l => l.Children.IncludeWithDefaultProperties());
var results = context.LoadQuery(quickLaunchNodeColl);
context.ExecuteQuery(); 
foreach (var result in results)
{
    foreach (var child in result.Children)
    {
        //find the child which has the url of our new list
        if(child.Url.Equals(list.DefaultViewUrl))
        {
            result.DeleteObject();
            context.ExecuteQuery();
        }
    }
}

@msft-github-bot
Copy link
Collaborator

This issue is being closed as part of an issue list cleanup project. Issues with no activity in the past 6 months that aren't tracked by engineering as bugs were closed as part of this inititive. If this is still an issue, please follow the steps outlined to re-open the issue.

@SharePoint SharePoint locked and limited conversation to collaborators Jan 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants