Service Portal: Custom Homepage Search Widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 07:43 AM
I'm attempting to customize a copy of the Homepage Search widget. The original is currently on the homepage of our Service Portal. It searches the Catalog, Knowledge Base, and Users.
For the copy, I want it on a different page as the company directory. So it would only show Users and exclude the Knowledge Base and Catalog search sources.
Below is the copied widget code I tried to modify:
HTML:
<div id="homepage-search" class="hidden-l wrapper-l">
<div class="wrapper-l" style="padding: 5px;">
<h2 class="text-center text-4x m-b-lg sp-tagline-color" ng-bind="options.title"></h2>
<div ng-if="options.short_description" class="text-center h4 m-b-lg sp-tagline-color" ng-bind="options.short_description"></div>
<!-- Display only the "Users" search source -->
<sp-widget widget="data.typeAheadSearch" source="'Users'" />
</div>
</div>
Server Script:
var aisEnabled = $sp.isAISearchEnabled();
if (aisEnabled) {
// Fetch the "Users" search source
data.typeAheadSearch = $sp.getWidget('typeahead-search', options);
data.typeAheadSearch.sources = data.typeAheadSearch.sources.filter(function(source) {
return source.name === 'Users';
});
} else {
data.typeAheadSearch = $sp.getWidget('typeahead-search', options.typeahead_search);
}
This still displays all the search sources.
I'm a bit of a novice when it comes to ServiceNow, so I'd love to hear any feedback on this! Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2023 10:56 AM
Hi @Alex Harrill
Its nothing to do with widget / script. You need to define the search sources. You can refer below
https://docs.servicenow.com/bundle/rome-servicenow-platform/page/build/service-portal/task/add-table...
Please mark as Accepted Solution / Helpful if you get it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 06:02 AM
Hi @Sohithanjan G,
I may have not been clear, so I apologize.
The Homepage Search widget is on our Service Portal homepage. I want to use the same widget on a different page of the same Service Portal. I've already defined the 3 search sources I've mentioned above.
But maybe I'm not understanding what you mean, if you don't mind elaborating 🙂 Thank you!