Service Portal - Change Sequence of Search Results

JimCheffer
Kilo Expert

The Service Portal search results return in this sequence.

find_real_file.png

We would like to change the sequence (Left Box) to Service Catalog, Knowledge Base and Question and Answers. Also the search results (list window on right) in the same sequence. Our goal is to direct users to the Service Catalog first. I found sys.properties "glide.service_portal.default_search_sources" and changed it to the sequence we want but it does nothing or is overwritten.Thanks in advance. Jim

1 ACCEPTED SOLUTION

You would have to clone and modify the Search Page widget.



In the HTML template, change:


<div role="listitem" ng-repeat="item in data.results | orderBy:'score':true | limitTo:data.limit" class="panel-body b-b ">


to


<div role="listitem" ng-repeat="item in data.results | limitTo:data.limit" class="panel-body b-b ">



In the server script, add orderBy call to this piece of code:


} else {


var m2mSearchSourceGR = new GlideRecord("m2m_sp_portal_search_source");


m2mSearchSourceGR.orderBy('order'); // <<-- ADD THIS LINE


if (data.t)


m2mSearchSourceGR.addQuery("sp_search_source.id", data.t);


m2mSearchSourceGR.addQuery("sp_portal", $sp.getPortalRecord().getUniqueValue());


m2mSearchSourceGR.query();


while(m2mSearchSourceGR.next()) {


var searchSourceGR = m2mSearchSourceGR.getElement("sp_search_source").getRefRecord();


data.resultTemplates["sp-search-source-" + searchSourceGR.getValue("id") + ".html"] = $sp.translateTemplate(searchSourceGR.getValue("search_page_template"));


getResults(searchSourceGR);


}


}


View solution in original post

15 REPLIES 15

Nia McCash
Mega Sage
Mega Sage

Check/change the order of your search sources in the related list at the bottom of your Portal [sp_portal] definition.


search_sources.jpg


Hello Nia, thanks I made the change and the left side now shows the sequence we wanted. Is there a way to show list in same sequence. Cart, then KB articles. Jim



find_real_file.png


You would have to clone and modify the Search Page widget.



In the HTML template, change:


<div role="listitem" ng-repeat="item in data.results | orderBy:'score':true | limitTo:data.limit" class="panel-body b-b ">


to


<div role="listitem" ng-repeat="item in data.results | limitTo:data.limit" class="panel-body b-b ">



In the server script, add orderBy call to this piece of code:


} else {


var m2mSearchSourceGR = new GlideRecord("m2m_sp_portal_search_source");


m2mSearchSourceGR.orderBy('order'); // <<-- ADD THIS LINE


if (data.t)


m2mSearchSourceGR.addQuery("sp_search_source.id", data.t);


m2mSearchSourceGR.addQuery("sp_portal", $sp.getPortalRecord().getUniqueValue());


m2mSearchSourceGR.query();


while(m2mSearchSourceGR.next()) {


var searchSourceGR = m2mSearchSourceGR.getElement("sp_search_source").getRefRecord();


data.resultTemplates["sp-search-source-" + searchSourceGR.getValue("id") + ".html"] = $sp.translateTemplate(searchSourceGR.getValue("search_page_template"));


getResults(searchSourceGR);


}


}


Thanks I will give it a try. Jim