I am working on a solution in SharePoint Online where I want to accomplish the following using CSOM:

  • Set all subsites to inherit search navigation from parent. To achieve this I have this little code-snippet which actually works and sets a property on a subsite web to inherit parent search navigation.

            using (ClientContext context = new ClientContext("ParentSiteURL"))
            context.Credentials = new SharePointOnlineCredentials(struser, password);
            Web web = context.Site.OpenWeb("SubsiteName");
            var allProperties = web.AllProperties;
            web.AllProperties["SRCH_VERT_SET_WEB"] = "{\"Inherit\":true}";

However, even though the property is updated and search settings are now set to inherit parent navigation - it's not working.

I need to navigate to "Site settings > Search settings" and click OK for it actually work. So it seems like I am missing an Update of some kind...

Any help would be much appreciated.

  • Do you have managed termset based navigation on rootsite? – DvG Jul 2 '18 at 7:46
  • Nope. I don't have any managed termset. – Ravi Jul 2 '18 at 7:50

I think you have to load it before execute

web.AllProperties["SRCH_VERT_SET_WEB"] = "{\"Inherit\":true}";
clientContext.Load(web, w => w.AllProperties);

as said in this post

| improve this answer | |
  • Already tried. Not Working :( – Ravi Jul 2 '18 at 8:47

Using the property SRCH_VERT_SET_WEB is probably not the right way to do it, since there is no documentation on the subject.

Try a more straight-forward approach like changing SPWeb.Navigation properties.

Check the propertiy values for UseShared and the list of navigation nodes in SearchNav before and after you modify search inheritance via site settings. You should be able to figure out what changed in the object model and then re-apply it in your code.

| improve this answer | |
  • I set UseShared property to true after loading all the navigation nodes. And still it does not work :( – Ravi Jul 2 '18 at 9:28
  • Finally I was able to achieve it using HttpPost method. Answered it on the originial question as I am unable to do answer it here. Thanks – Ravi Aug 1 '18 at 10:40

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