Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

In SharePoint 2013, I am trying to access Search object through JavaScript CSOM.

I want to know the object which can give me the access to Search Settings under Site Settings. I tried looking under SP object but I didn't find any Search related object there.

My goal is to change the search Center URL through JavaScript CSOM.

Thanks in Advance!!!

share|improve this question

1 Answer

Although there is currently no API in the JavaScript CSOM which lets you change the search center url directly, SharePoint stores the search settings in the Property Bag of the root SPWeb object in a sitecollection. You can set these property bag values and your search settings should get modified.

"SRCH_ENH_FTR_URL" – Search Center URL

"SRCH_SITE_DROPDOWN_MODE" – Search Scope Drop down option

"SRCH_TRAGET_RESULTS_PAGE” – Target Search Results page

Using JavaScript CSOM, you can set the values like this:

var ctx = new SP.ClientContext.get_current();
var web = ctx.get_site().get_rootWeb();
var props =  web.get_allProperties();

props.set_item("SRCH_ENH_FTR_URL","/sites/search/pages");
web.update();
ctx.load(web);

ctx.executeQueryAsync(function () {
    alert(props.get_item("SRCH_ENH_FTR_URL"));
 },
 function() {
  alert("failed");
});
share|improve this answer
Hey Vardhaman...thanks bunch for your response....Actually I have implemented this in exactly the way you are describing here....but Happy to hear that I also implemented the same solution.... – nks Mar 18 at 5:59
Though I have one issue which is really killing me when I am setting Master Page....would be great if you could throw some light on this..... Master Page Error Issue – nks Mar 18 at 6:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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