Search knowledge topic returning links to kb_view.do - why not portal?

miriamberge
Tera Guru

Hi,  I copied the out of box Search for knowledge topic.  Works fine in returning links for my searches, however the actual link is directing users to the standard interface kb_view.do page.  Ideas on where I configure this?  Property?  I don't see anything in the actual topic or virtual agent settings that I need to configure for this.  Odd thing is that this worked fine in New York, directed user to the service portal kb_article page.  I cloned and upgraded one of our non prod instances to Orlando and now the user is getting directed to standard interface.  Thanks! 

1 ACCEPTED SOLUTION

Kenton Dover
Mega Guru

I noticed this with the contextual search when we were displaying catalog items. The code below is for catalog items but if you change it around it should work for knowledge base items too.

This is the ootb code for the display kbs link handler.

var linkBuilder = new global.cxs_SearchResultLinkBuilder();
for (var i = index; i < index + limit && i < searchJsonObj.length; i++) {
	var link = linkBuilder.build(searchJsonObj[i], vaInputs.portal);
	groupedLinksOutMsg.addLinkPart(link.label, link.link, link.description, link.context_label);
}

I changed this to

var linkBuilder = new global.cxs_SearchResultLinkBuilder();
for (var i = index; i < index + limit && i < searchJsonObj.length; i++) {
	var link = linkBuilder.build(searchJsonObj[i], vaInputs.portal);
	if(link && link.link){
	        url = link.link;
                if(url.includes("cxs_cat_item.do?")){
		       url = url.replace("cxs_cat_item.do?sysparm_id", "sp?id=sc_cat_item&sys_id");
	        }
	        groupedLinksOutMsg.addLinkPart(link.label, url, link.description, link.context_label);
	}else{
	        index++;
	}
		
}

Note that the line url = url.replace is what you would need to change for the knowledge base. 

View solution in original post

7 REPLIES 7

Abdul Ismail
Kilo Contributor

I changed the "vaInputs.portal" parameter in the linkBuilder to the portal name, seems to do the trick. I couldn't find any reference to vaInputs.portal in the conversation, not sure why its there. 

var linkBuilder = new global.cxs_SearchResultLinkBuilder();
for (var i = index; i < index + limit && i < searchJsonObj.length; i++) {
	var link = linkBuilder.build(searchJsonObj[i], "sp");
	groupedLinksOutMsg.addLinkPart(link.label, link.link, link.description, link.context_label);
}

You can put the portal name in a variable instead of hard coding it in the script. 

Community Alums
Not applicable

Hello,

ServiceNow has a Knowledge Article for this topic. - KB0961011 - How to redirect knowledge article link in VA Agent search result to portal instead of na...

I thought this would be helpful.

Good find.

Though, it would be ideal that the portal suffix is not hard-coded.