- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2022 08:08 AM
Hello Team,
I recently built Topics on the virtual agent designer for searching KB Articles, and everything appears to be working well with the exception of one thing: when I click on the link, it redirects to backend view rather than portal view. I have no idea why this is behaving oddly. Please let me know what needs to modified if you can.
Verified Script Include as well it looks good
Current View :
Required View:
Thanks,
JRY
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2022 03:40 AM
Hi Jry,
I can tell that the code is perfect. Pls validate to see if "portal" is coming from the right place. Verify it in the Virtual agent designer's Display links on the Topics flow. Test whether hard coding the portal url suffix will work.
Regards,
Chaitanya
If my answer helps in any way please mark it helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2022 07:46 PM
Something wrong with the variables in line 46 maybe? (this._baseURL or portal)
Try logging out the link that is constructed in line 46.
A missing forward slash could be a reason for system to reroute from portal to native view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2022 08:22 PM
Hi Anirudh,
Thanks for the reply, i have verified the code it looks good for me. Can you please verify entire code below and help me please what needs to be change.
var cxs_SearchResultLinkBuilder = Class.create();
cxs_SearchResultLinkBuilder.prototype = {
initialize: function() {
this._baseURL = gs.getProperty('glide.servlet.uri');
},
build: function(contextualSearchResult, portal) {
var id = contextualSearchResult.id.split(':');
var resourceType = id[0];
var resourceId = id[1];
var link = {
"label": contextualSearchResult.title,
"link": this._getResourceURL(contextualSearchResult.link),
"description": contextualSearchResult.snippet.substring(0, 240),
"context_label": !gs.nil(contextualSearchResult.meta.card_label) ? contextualSearchResult.meta.card_label : contextualSearchResult.meta.source
};
var urlSuffix = this.getURLfromFullView(contextualSearchResult.meta.full_view_url);
if (resourceType == "kb_social_qa_question") {
if (contextualSearchResult.meta.accepted) {
if (!gs.nil(portal)) {
link.link = this._baseURL + portal + "?id=kb_social_qa_question&sys_id=" + resourceId;
}
} else if (contextualSearchResult.meta.source == "community_question") {
link.context_label = gs.getMessage("Community Discussion");
var gr = new GlideRecord("kb_social_qa_question");
gr.get(resourceId);
if (!gs.nil(gr.accepted_answer)) {
if (!gs.nil(portal)) {
if (!gs.nil(urlSuffix)) {
link.link = this._baseURL + portal + urlSuffix;
} else {
link.link = this._baseURL + portal + "?id=community_question&sys_id=" + resourceId;
}
}
} else {
return {};
}
} else {
return {};
}
} else if (resourceType == "kb_knowledge") {
if (!gs.nil(portal)) {
link.link = this._baseURL + portal + "?id=kb_article&sys_id=" + resourceId;
}
} else if (resourceType == "sn_communities_blog") {
link.context_label = gs.getMessage("Community Blog");
if (!gs.nil(portal)) {
if (!gs.nil(urlSuffix)) {
link.link = this._baseURL + portal + urlSuffix;
} else {
link.link = this._baseURL + portal + "?id=community_blog&sys_id=" + resourceId;
}
}
} else if (resourceType == "kb_social_qa_answer") {
return {};
} else if (resourceType == "sc_cat_item") {
if (!gs.nil(portal)) {
link.link = this._baseURL + portal + "?id=sc_cat_item&sys_id=" + resourceId;
} else
link.link = this._baseURL + "com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=" + resourceId;
}
return link;
},
getURLfromFullView: function(fullViewURL) {
if (!gs.nil(fullViewURL)) {
var url = fullViewURL.split('?');
return "?"+url[1];
}
return '';
},
_getResourceURL: function (srcResultLink) {
if (srcResultLink.startsWith('http') || srcResultLink.startsWith('www'))
return srcResultLink;
return this._baseURL + srcResultLink;
},
type: 'cxs_SearchResultLinkBuilder'
};
Thanks,
JRY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2022 03:40 AM
Hi Jry,
I can tell that the code is perfect. Pls validate to see if "portal" is coming from the right place. Verify it in the Virtual agent designer's Display links on the Topics flow. Test whether hard coding the portal url suffix will work.
Regards,
Chaitanya
If my answer helps in any way please mark it helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2022 03:53 AM
Thank you, Chaitanya. I tried your solution by hard coding the url suffix, and as you can see, it's now bringing me to kb article view with no problems.
Thanks,
JRY