How to populate short description along with the number when searched in the homepage search widget of a service portal ?

sumana1707
Mega Contributor

Dear All,

I am very new to service portal. Please let me know how to populate short description along with the number when searched in the homepage search widget of a service portal ?

For example. if I give INC039.... , it should populate all the incidents stating with INC039... alond with the short description placed beside the incident number.

It should be applicable for REQ, KB, TASK etc also.

I appreciate all the help from you.

Regards,

Sumana

1 ACCEPTED SOLUTION

Manoj Kumar16
Giga Guru

Hi Sumana,



You need to create a scripted Data Source for the Incidents. In the scripted Data Source add



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




var inc = new GlideRecordSecure('incident');


inc.addQuery('123TEXTQUERY321', query);


inc.addQuery('active',true);


inc.addQuery('no_search', '!=', true);


inc.addQuery('caller', gs.getUserID());


inc.query();


var RowCount = 0;


while (inc.next() && RowCount < data.limit) {


var item = {};


item.type = "inc";


item.page = "ticket";




$sp.getRecordDisplayValues(item, inc, 'number,short_description');



item.score = parseInt(inc.ir_query_score.getDisplayValue());


item.label = item.number;


item.desc=item.short_description;


item.primary = item.number;


item.id=item.sys_id;


item.url = '?id=' + item.page +'&table=incident'+'&sys_id=' + inc.getUniqueValue();



results.push(item);


RowCount++;


}


return results;


})(query);




In this article you will find how can you use the Advance Typeahead Template to put whichever fields you want to dsplay


Create an advanced typeahead template



Create the advance typeahead template -



<span ng-bind-html="match.label | uibTypeaheadHighlight:query"></span>    


<span ng-bind-html="match.model.short_description | uibTypeaheadHighlight:query"></span>



Please note the text marked in BOLD in both scripts, In this way you add whichever field you want to display.


View solution in original post

13 REPLIES 13

Can you paste the scripted source and the advance type ahead template here ?


Community Alums
Not applicable

hi Sumana,

how to limit the short_description text on service portal search.like i how we get only inside of white portion of Search data.

 

find_real_file.png

Community Alums
Not applicable

Hi Kuma,

i have same requirement i did but when the short description is too big the data overflow the out of white portion. 

Could you please help me how to limit the short description.

find_real_file.png

Manoj Kumar16
Giga Guru

Hi Eivind,



Yes, even that works.