4

This question already has an answer here:

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;
            context.Load(allProperties);
            web.AllProperties["SRCH_VERT_SET_WEB"] = "{\"Inherit\":true}";
            web.Update();                
            context.ExecuteQuery();
            }
    

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.

marked as duplicate by MHeld, Robert Lindgren, P S, Gaurravs, Dikesh Gandhi Jul 4 '18 at 11:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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
0

I think you have to load it before execute

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

as said in this post

  • Already tried. Not Working :( – Ravi Jul 2 '18 at 8:47
0

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.

  • 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.