How to change the options in search drop down with CSOM


You can change the options in the drop down manually by going to Site Settings > Search > Search Settings and add or remove a link.


If you want to change the options of the drop down in the search bar, you unfortunately have to configure these for each web and not just for the root site collection. So you probably don’t want to configure it manually.

As you can’t you SSOM in SharePoint online you have to use the CSOM. You can’t access the search navigation in a “normal” way, because there is no object in CSOM for it. But you can get the search Navigation by its id (Thanks for the idea, Mikael):

public static void AddSearchNavigationNode(Web web, string title, string url)
var nav = web.Navigation;
NavigationNode searchNavigation = nav.GetNodeById(1040);
NavigationNodeCollection searchNavigationNodeCollection = searchNavigation.Children;
NavigationNodeCreationInformation searchNavigationNode = new NavigationNodeCreationInformation();
searchNavigationNode.Title = title;
searchNavigationNode.Url = url;
searchNavigationNode.IsExternal = true;
searchNavigationNode.AsLastNode = true;

Please note that all the default options (Everything, People, This site) are getting removed, when adding a custom option via code.

2 thoughts on “How to change the options in search drop down with CSOM

  1. Hey Atia,
    sounds good and fits our requirements. But, how did you come across the 1004 – is there any list with standard ids?

    • Unfortunately there isn’t a list with standard ids. At least as far as I know.
      Microsoft hasn’t implemented all the CSOM properties, that’s why we have to use the id here. You can find out the id for the search navigation using Reflector.

Leave a Reply

Your email address will not be published. Required fields are marked *