
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2020 10:11 AM
When following the above example, the code below does not display any results:
(function(query, queryLocation, count) {
var results = [];
/* Calculate your results here. */
var userGR = new GlideRecord('sys_user');
userGR.addQuery('active', true);
userGR.addQuery('name', 'CONTAINS', query);
userGR.query();
userGR.setLocation(queryLocation - 1);
var resultCount = 0;
while(userGR.next() && resultCount < count + 1){
var obj = {};
obj.sys_id = userGR.getUniqueValue();
obj.primary = userGR.getDisplayValue();
obj.query_location = userGR.getLocation();
obj.label = userGR.getDisplayValue();
results.push(obj);
resultCount++;
}
if(results.length == 0)
return results;
if(results.length > count) {
results.pop();
} else {
// In order to indicate that a result in the result
// set is the final result (that there are
// no more results to be fetched), add this property
// to the final element in your result set.
results[results.length - 1].isLastResult = true;
}
return results;
})(query, queryLocation, count, facets);
The typeahead works but the results page does not.
Why is it not working?
Solved! Go to Solution.
- Labels:
-
Search
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2020 02:23 PM
The search facet needed to be enabled.
https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/build/service-portal/task/enable-facets.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2020 11:41 PM
Hello,
Did you manage to get this working with a scripted query? If so, what was the outcome.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2020 09:16 AM
I'm running into the same issue, using the script debugger it seems like the value for queryLocation never changes. Would like to know if anyone finds a solution!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2020 02:23 PM
The search facet needed to be enabled.
https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/build/service-portal/task/enable-facets.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2020 07:27 AM
After further investigation, I found that in the faceted search widget there is a point where the value for 'obj.query_location' gets coerced into a string yet treated like a number. If you are having an issue where the pagination keeps loading the same results, this can be fixed by cloning the widget and coercing the query_location value into a number. In the client script, pass last.query_location into the parseInt function:
function generatePagination(results, previousIndex) {
var last = results[results.length-1];
$scope.showPagination = true;
$scope.showLoadMore= last && !last.isLastResult;
if(last && last.query_location != undefined) {
$scope.query_start_location = parseInt(last.query_location) + 1;
} else {
$scope.query_start_location = 0;
}
if(previousIndex > 0) {
setFocusNextItem(previousIndex);
}
}