- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 08:08 AM
Within the Virtual Agent I am able to display filtered/search results using the "Table" or "Card" response, however, there is no ability for the user to click on a result and be directed to that record. Is there an OOTB approach in Virtual Agent to allow a user to click on a result, for example in the "Table" response, and be directed to that record either in a portal or viewing the record in the list directly?
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 02:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 10:29 AM
Hi,
Have you seen this knowledge article? It might help a lot with this requirement: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743562
If my answer has helped or solved your query please mark it as so.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 01:49 PM
The kb article mentioned above provides an example script response. So there is no way to do this without writing custom script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 02:25 PM
Hi Joseph,
I am looking at the OOTB topic for Checking IT tickets [incidents/requests]
Once it has found an incident, it is showing the incident card with a link in the top right.
(function execute() {
var tableName = vaVars.table_name;
var recordId = vaVars.sys_id;
var link = '';
var screenId = '';
if (vaVars.portalName === 'mesp') {
var mobileDLink = new global.MobileDeepLinkGenerator('request');
if (tableName == 'sc_req_item')
screenId = '7516f9d787232300e0ef0cf888cb0b4d';
else if (tableName == 'sc_request')
screenId = '276dd3edb79033001befcd58de11a9c7';
else if (tableName == 'incident')
screenId = 'ebb94d9c0f2033001befa68ca8767e4e';
else
screenId = 'd39eb2db87772300e0ef0cf888cb0bcb';
link = mobileDLink.getFormScreenLink(screenId, tableName, recordId);
} else {
link = vaVars.baseUri + vaVars.portalName + "?id=ticket&table=" + tableName +"&sys_id=" + recordId;
}
var title = '';
var subtitle = '';
var fields = [];
var gr = new GlideRecord(tableName);
gr.addQuery('sys_id',recordId);
gr.query();
title = gr.getClassDisplayValue();
if(gr.next()){
subtitle = gr.number.toString();
if( !gs.nil(gr.getDisplayValue('short_description').toString()) ){
fields.push({"fieldLabel": gr.getElement('short_description').getLabel(), "fieldValue": gr.getDisplayValue('short_description').toString()});
}
fields.push({"fieldLabel": gr.getElement('state').getLabel(), "fieldValue": gr.getDisplayValue('state').toString()});
if( !gs.nil(gr.getDisplayValue('assigned_to').toString()) ){
fields.push({"fieldLabel": gr.getElement('assigned_to').getLabel(), "fieldValue": gr.getDisplayValue('assigned_to').toString()});
}
fields.push({"fieldLabel": gr.getElement('sys_updated_on').getLabel(), "fieldValue": gr.getDisplayValue('sys_updated_on').toString()});
var count = 0;
var grComments = new GlideRecord('sys_journal_field');
grComments.addQuery('element_id', recordId);
grComments.addQuery('name', tableName);
grComments.addQuery('element', "comments");
grComments.orderByDesc('sys_created_on');
grComments.setLimit(vaVars.max_comment_count);
grComments.query();
while (grComments.next()) {
var commenter = [];
var user = new GlideRecord('sys_user');
user.get('user_name', grComments.sys_created_by);
var userName = user.getDisplayValue("name");
commenter.push(userName);
var now = new GlideDateTime();
var schedule = new GlideSchedule();
schedule.load('38fa64edc0a8016400f4a5724b0434b8');
var start = new GlideDateTime(grComments.getValue("sys_created_on"));
var duration = schedule.duration(start, now);
if (duration.getRoundedDayPart() > 1)
var elapsedTime = gs.getMessage("{0} days ago", [duration.getRoundedDayPart()]);
else if (duration.getRoundedDayPart() == 1)
var elapsedTime = gs.getMessage("{0} day ago", [duration.getRoundedDayPart()]);
else
var elapsedTime = gs.getMessage("{0} ago", [duration.getDisplayValue()]);
var comment = grComments.value.replace(/<\/?[^>]+(>|$)/g, "");
var comments = [ commenter, " - ", elapsedTime, " : ", comment];
var displayComments = comments.join("");
if(displayComments.length >= vaVars.comments_length) {
var editComments = [ displayComments.substring(0, vaVars.comments_length) , '...' ];
displayComments = editComments.join("");
}
if(count == 0) {
fields.push({"fieldLabel": gr.getElement('comments').getLabel(), "fieldValue": displayComments});
} else {
fields.push({ "fieldValue": displayComments});
}
count++;
}
}
var card_data = JSON.stringify({
"title":title,
"subtitle":subtitle,
"fields":fields,
"url":link.toString()
});
return vaSystem.renderCard("Card", card_data);
})()
The link is defined:
link = vaVars.baseUri + vaVars.portalName + "?id=ticket&table=" + tableName +"&sys_id=" + recordId;
and then set to the var card_data.url field, which is passed as a parameter to vaSystem.renderCard("Card", card_data); at the end of the script.
So ultimately, I don't think there's really another approach as close to this one is OOTB. Ofcourse, if you were to use a script like this, you can change what is defined as the "link" to meet your requirement.
If my answer has helped or solved your query please mark it as so.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 02:05 PM
I will have to write a script. Understood.