How to redirect to portal page based on search keywords - PORTAL

Sironi
Kilo Sage

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.

find_real_file.png

Kindly suggest me how to do this functionality 

1 ACCEPTED SOLUTION

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.

View solution in original post

42 REPLIES 42

Hi Asif,

 

it is working sucessfully.

var CovidnewUrl = $location.search({
id:'portal_page',
page:'f409a13a1b9b4410ccc28444cc4bcb1e'
});


spAriaFocusManager.navigateToLink(CovidnewUrl.url());

 

can we do same form in side of search

find_real_file.png

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.

Not sure, what you meant inside of form search?

Can you elaborate.

sure Asif,

 

when we enter keywords and click on search button it will redirect to another page

 

if you see in second image small search box on top side.

so from here  also if we tried to search with our keywords then it has to redirect to respective Portal page...

this is the usecase.

i hope you understood the usecase.

find_real_file.png

 

Check which widget is that code coming from. I think its another widget. You might have to follow same procedure as we did earlier for this as well.