Search by REQ# on ServiceNow Portal

Raza156
Kilo Contributor

Currently, on our Service Portal, we can search by RITM# as shown below

find_real_file.png

However, when we try to search for the same RITM through its REQ number, it shows nothing:

find_real_file.png

 

Is there a script that needs to be added? If yes, what sort of script needs to be added?

2 REPLIES 2

SanjivMeher
Kilo Patron
Kilo Patron

Open your portal and there will be search sources linked to your portal at the bottom. Click on the respective search sources to identify how it is done.

find_real_file.png

 

 

You may also check System Definition->Search Groups, if Request is added to the Task Search Group

 

find_real_file.png


Please mark this response as correct or helpful if it assisted you with your question.

Hey Sanjiv,

 

I just checked Search Groups in System Definition I do have a request group set to true. It is also called sc_request, just as it shows in your screenshot. 

 

I did open the Portal as you said and it looks like it is in your screenshot. But I do not know what to do with it.


Like the Data Fetch Script is:

(function(query) {
	var results = [];
	//Here goes the logic. Compute results however you want!
	if (!gs.isLoggedIn())
		return results;

	var sc = new GlideRecord('sc_cat_item');
	sc.addQuery('123TEXTQUERY321', query);
	sc.addQuery('active',true);
	sc.addQuery('no_search', '!=', true);
	sc.addQuery('visible_standalone', true);
	sc.addQuery('sys_class_name', 'NOT IN', 'sc_cat_item_wizard');
	var portalValue = $sp.getValue('sc_catalog');
	if (portalValue)
		sc.addQuery('sc_catalogs', portalValue);
	sc.query();
	var catCount = 0;
	while (sc.next() && catCount < data.limit) {
		if (!$sp.canReadRecord(sc))
			continue;

		var item = {};
		item.type = "sc";
		item.page = "sc_cat_item";

		if (sc.getRecordClassName() == "sc_cat_item_guide")
			item.page = "sc_cat_item_guide";
		else if (sc.getRecordClassName() == "sc_cat_item_content") {
			var gr = new GlideRecord('sc_cat_item_content');
			gr.get(sc.getUniqueValue());
			$sp.getRecordValues(item, gr, 'url,content_type,kb_article');
			item.type = "sc_content";
		}
		else
			item.type = "sc";

		$sp.getRecordDisplayValues(item, sc, 'name,short_description,picture,price,sys_id,sys_class_name');
		item.score = parseInt(sc.ir_query_score.getDisplayValue());
		item.label = item.name;
		item.primary = item.name;

		//calculating URL
		if (item.type == "sc")
			item.url = '?id=' + item.page + '&sys_id=' + item.sys_id;
		if (item.type == "sc_content") {
			if (item.content_type == "kb")
				item.url = '?id=kb_article&sys_id=' + item.kb_article;
			else if (item.content_type == "external")
				item.target = '_blank';
			else
				item.url = '?id=sc_cat_item&sys_id=' + item.sys_id;
		}
		if (item.type == "sc_guide")
			item.url = '?id=sc_cat_item_guide&sys_id=' + item.sys_id;

		results.push(item);
		catCount++;
	}

	return results;
})(query);

 

Is there anything specific I need to write?