About Servicenow Global search

mandy2
Kilo Contributor

Hello all,

Do anyone know well about servicenow global search? I am now experiencing an issue. User with PPS role(self customized role) searches for the term, for example 'taleo'. No results were returned but the user, navigating by the click tree, can find several Taleo related knowledge articles. Please see screenshots.

find_real_file.png

find_real_file.png

find_real_file.png

When I grant user with admin role, the search function can work correctly.   looks like something else restrict the search result according to different role?

I checked ALC, text_search_admin role is required to query data from global search (ts_query) table. Not sure if it is the issue.

Below is the search script:

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<div class="content_list_title">${gs.getMessage('Search')}</div>

<form name="content_search" id="content_search" action="search_results.do" method="post" style="padding-left:5px; padding-bottom:10px;">

                                            <input type="HIDDEN" value="${current_page.getSiteID()}" name="sysparm_current_site"/>                      

                                            <span class="globalSearch contextSearch" >

                                                    <g:text_search_widget size="24"/>

                                            </span>

                               

</form>

<script>

  var ajax = new GlideAjax("TextSearchAjax");

  ajax.addParam("sysparm_name", "recent");

  ajax.getXML(adjustSearchResponse);

  function adjustSearchResponse(request) {

      var answer =   request.responseXML.documentElement.getAttribute("answer");

      if (answer != null) {

      var gcm = new GwtContextMenu('context_search');

        gcm.clear();

              if (answer.indexOf("xyzzyx") != 0) {

          var db = answer.split("^");

          for (var i = 0; i != db.length; i++) {

          gcm.addHref(db[i], "content_search('"+db[i]+"')");

        }

  } else gcm.addLabel(answer.substr(6));

      }

  }

function content_search(term) {

    gel('content_search').sysparm_search.value=term;

    gel('content_search').submit();

}

</script>

</j:jelly>

Here is the TextSearchAjax code, need to query data from ts_query:

var TextSearchAjax = Class.create();

TextSearchAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {

  process: function() {

          if (this.getName() == "recent")

                  return this.getRecentSearches();

  },

  getRecentSearches: function() {

          var answer = new Array();

          var i = 0;

          var hp = new GlideRecord('ts_query');

          hp.addQuery('user', gs.getUserID());

          hp.orderByDesc('sys_updated_on');

          hp.setLimit(10);

          hp.query();

          if (!hp.hasNext())

                  answer.push("xyzzyx" + gs.getMessage("No recent searches"));

          else {

                  while (hp.next()) {

                          answer.push(hp.search_term.toString());

                          i++;

                  }

          }

          return answer.join('^');

  },

 

  isPublic: function() {

      return false;

  },

 

  type: "TextSearchAjax"

});

4 REPLIES 4

mandy2
Kilo Contributor

Hi all,


I think I fix the issue by 2 settings. Paste the solution here for knowledge sharing.


1. Add the role to global text search, to let it can use the global text search capability.


find_real_file.png



2. Add the role to search group, so that the platform can pull data from the KB.


find_real_file.png


Brad Tilton
ServiceNow Employee
ServiceNow Employee

Looks like you've found it, but the search groups is the best place to administer global search if you're going to show it through the cms.


Hi Brad ,



        I have client requirement to add more groups in the Text Search Group like Ritm and other tables extending task .They also want to remove active is true conditions Text Search task Tables .At present they have condition active is true for all the tables Could   you please Suggest   any best practices for Text Search Groups or   Tasks under the Text Search Group.How will be the performance effected in the long run Please find the attached screen shot for reference.Please suggest me best Practices                                                                                                                                                                           find_real_file.png


Hi Zhao,



How can we restrict Knowledge & Catalog search items should not visible for HR team members? Please suggest solution for the same.



Thanks & Regards,


Prasanna Kumar