- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-24-2020 02:23 PM
Hi all,
Some one suggest me please how to redirect to Portal page based on search Keyword
Ex: when i type Covid19 or coronavirus in search bar automatically it should be navigate to Covid Portal page.
So how can we do this.
if it is not possible to navigate Page , it will be great at least if we show Page url as result .
Keywords : Covid, covid-19, workplace, exposure, travel restrictions, social distance, health, health assessment, coronavirus, covid testing
automatically it has to redirect to Covid-19 page.
Kindly suggest me how to do this functionality
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-28-2020 06:59 AM
Okay great. Here is complete working code for reference.
c.submitSearch = function() {
//--------------------------Covid 19-------------------------------//
//alert(c.searchTerm);
var searchablePagesWhitelist = ['Covid', 'Testing', 'covid', 'covid-19', 'workplace', 'exposure', 'travel restrictions', 'social distance', 'health', 'health assessment', 'CDC', 'coronavirus', 'covid testing'];
var searchablePagesWhitelistMVVp = ['MIssion', 'mission', 'Vision', 'US Eagle', 'SOUL', 'people'];
var searchablePagesWhitelistssp = ['KPI', 'Success Sharing', 'Operating Expenses', 'Member Service'];
if (searchablePagesWhitelist.indexOf(c.searchTerm) > -1) {
// alert("Entered into if condtion");
var CovidnewUrl = $location.search({
id: 'portal_page',
page: 'f409a13a1b9b4410ccc28444cc4bcb1e'
});
spAriaFocusManager.navigateToLink(CovidnewUrl.url());
//var my_url = '/sp?id=portal_page'+'&'+'page'+'='+'f409a13a1b9b4410ccc28444cc4bcb1e';
//spAriaFocusManager.navigateToLink(my_url.Url());
} else if (searchablePagesWhitelistMVVp.indexOf(c.searchTerm) > -1) {
// alert("Entered into MVVP if condtion");
var MVVPnewUrl = $location.search({
id: 'credit_union_page'
});
spAriaFocusManager.navigateToLink(MVVPnewUrl.url());
} else if (searchablePagesWhitelistssp.indexOf(c.searchTerm) > -1) {
// alert("Entered into SSP if condtion");
var SSPnewUrl = $location.search({
id: 'kpi_main_page',
sysparm_domain_restore: 'false',
sysparm_stack: 'no'
});
spAriaFocusManager.navigateToLink(SSPnewUrl.url());
} else if (searchablePagesWhitelistSPPP.indexOf(c.searchTerm) > -1) {
// alert("Entered into if condtion");
var SPPPnewUrl = $location.search({
id: 'portal_page',
page: '36762d99db2ecc507203d12c5e9619d5'
});
spAriaFocusManager.navigateToLink(SPPPnewUrl.url());
} else {
//------------------------------------------------------------------------------//
Kindly mark the comment as a correct answer and other comments as helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-25-2020 08:53 AM
I can give you an idea , generally the portal redirection is mainly based on user's role
but if you want to do it based on the search term then you would have to query the table
"ts_query_kb" to confirm whether the term searched is covid or not and if it is covid then redirect to different page ( i mean portal) ...
Just append this code to the redirection code and you could get the results
Steps for redirection is given in below blog
Check the section (Setting up a role-based redirection)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-25-2020 09:04 AM
Hi,
Thanks for reply,
when i tried to search with word, it was redirected to list of KB articles . kindly give me some background process how to do this .
if word matched with from list {Covid, covid-19, workplace, exposure, travel restrictions, social distance, health, health assessment, coronavirus, covid testing} automatically open Covid19 portal page.
kindly help with some background .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-25-2020 11:29 AM
i tried this format , but i m not sure it is Correct or not . but unfortunate i didn't get any result
i tried with OOB search source Pages? "sp_search_source.list" ? i have cloned Pages
and added my content in dictionary but not working
Search Page Template:
<div>
<a href="{{item.url}}" target="{{item.target}}" class="h4 text-primary m-b-sm block">
<i class="fa fa-link m-r-sm"></i>
<span ng-bind-html="highlight(item.title, data.q)"></span>
</a>
<span class="text-muted">
<span class="text-muted" ng-bind-html="highlight(item.short_description, data.q)"></span>
</span>
</div>
Data fetch script section :
var searchablePagesWhitelist = ['Covid', 'Testing', 'covid', 'covid-19', 'workplace', 'exposure', 'travel restrictions', 'social distance', 'health', 'health assessment', 'CDC', 'coronavirus', 'covid testing'];
(function(query) {
var results = [];
if (!gs.isLoggedIn())
return results;
//'and' for 'addQuery' | 'or' for 'addOrQuery'
var fieldNames = [
['and', 'roles', '=', 'security_dashboard_user'],
['and', 'short_description', 'CONTAINS'],
['or', 'title', 'CONTAINS']
];
results = new ISCSearch().searchFromTableFields(fieldNames, 'sp_page', query);
//Set URL and Target, remove non-whitelisted page results
for (var i = 0; i < results.length; i++) {
if (!this.isWhitelistedPageResult(results[i]['title'].toString())) {
results.splice(i, 1);
} else {
results[i]['url'] = '/sp?id=' + results[i]['id'];
results[i]['target'] = '_self';
if (results[i]['id'].contains('covid')) {
results[i]['url'] += 'covid19';
}
}
}
return results;
})(query);
function isWhitelistedPageResult(current_page) {
return (searchablePagesWhitelist.indexOf(current_page) > -1);
}
URL

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-27-2020 09:54 PM
Hello Sironi,
Could you print the value of results [i]['id'] and check what value you are gettting?
results[i]['url'] = '/sp?id=' + results[i]['id'];
Also add a static url and check first whether your code is working or not.
Mark the comment as helpful if it helps.