Friday 15 March 2013

Modify Search Center Settings with JavaScript Client Object Model


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 site collection. 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 Client Object Model, you can set the values like this:

For the Search Scope Drop Down Options, here is a full set of values you can set:

Do Not Show Scopes Dropdown, and default to contextual scope: "HideScopeDD_DefaultContextual"
Do Not Show Scopes Dropdown, and default to target results page: "HideScopeDD"
Show scopes Dropdown: "ShowDD"
Show, and default to ‘s’ URL parameter: "ShowDD_DefaultURL"
Show and default to contextual scope: "ShowDD_DefaultContextual"
Show, do not include contextual scopes: "ShowDD_NoContextual"
Show, do not include contextual scopes, and default to ‘s’ URL parameter: "ShowDD_NoContextual_DefaultURL"

2 comments:

Unknown said...

hi mate.
thanks for the blog.

Do you know if there is any JSOM/CSOM approach of modifying search navigation too? I mean adding new links for dropdown (same as you would do if you go to Search Settings in site level and add links for search navigation).

Cheers
Hrayr

Vardhaman Deshpande said...

Hi Hrayr,

I just saw your comment sorry. Yes I think it is possible. Here is the link:
http://techmikael.blogspot.co.uk/2014/10/retrieving-and-working-with-search.html