- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020 07:13 AM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020 12:28 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020 12:28 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2020 10:53 AM
Thanks... curious why this changed between New York - in New York you can see how they construct the link right in the script response but in Orlando it just uses linkbuilder... wondering if there is additional configuration that I need to update so that this works oob in Orlando? I will update the code - thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2021 02:34 AM
Came across this question and answer as I hit this very same issue with my current customer on the Paris release. It did give a clue as to what to look at.
I observed that vaInputs.portal is not defined, so looked around and did not find inputs in the conversation flow that would set it.
My approach to resolve this was to avoid hard-coding and create a new Script Variable to track the portal, which I called portal and set it with the following script
if (vaContext.portal != '')
return vaContext.portal;
return gs.getProperty('sn_itsm_va.com.snc.itsm.virtualagent.portal_url');
Then for the linkBuilder, changed the parameter from vaInputs.portal to vaVars.portal.
The usage of vaContext would allow you to grab values from the Service Portal Agent Chat script. So I would just add the following line to the object.
portal: $sp.getValue('url_suffix')
If you do not set the portal in the Agent Chat script, then the value will fall back to using the property (comes with the ITSM Virtual Agent Conversations plugin).
This method was chosen to cater for changing portal names and if you use this in more than one portal and not needing to hard-code values.
Of course, you can skip the creation of the Script Variable and do all the checks in the same Response block (check for vaInputs.portal, then check vaContext, then check the property, then fallback to hard-coded value if desired).
I hope this is of help should someone else face a similar issue.
EDIT: Corrections and formatting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 02:13 AM
Hi , I want to know from where i can navigate this code and do the expected changes .
My query related to the kb articles which comes via contextual search and when we click on that via chat bot it redirects the native view not portal