Virtual Agent Card Output Not Displaying Reference Fields

Aaron32
Kilo Explorer

When using the Bot Response type "card" in the virtual agent designer if you select a field to display and that field happens to be a reference field when the card is rendered the reference fields display as empty even if they are filled out in the record. 

 

Is there any way to get the standard card response to display reference fields, or do we just have to create a script output like they did in the "Open IT Ticket" ITSM topic if we want to display reference fields?

 

Edit: I have not gotten reference fields to display properly using card output or script output. 

Script output code:

(function execute() {
      var item = new GlideRecord('sc_req_item');
      item.addQuery('request', vaVars.created_req_id);
      item.query();
      
      if (item.next()) {
            var title = {
                  url: gs.getProperty('glide.servlet.uri') + '/',
                  label: item.number
            };
            var fieldList = ['short_description', 'cmdb_ci', 'business_service', 'service_offering', 'assignment_group'];
            var cardRenderer = new global.VaRecordCardRenderer(true);
            var fields = cardRenderer.createFields(fieldList, item);
            var html = cardRenderer.renderCard(title, fields);
            return html;
      }      
})();

 

Card Configuration:

find_real_file.png

 

Yet this is what happens when the topic is run, the REQ and RITM are created and do have all the fields selected populated in the table record but they just will not display in the bot response. (First response is the Script Output, second is the Card Response)
find_real_file.png

3 REPLIES 3

Michael Lee1
Tera Expert

Not an answer to your question, but where did you find the properties and methods for the card bot response? 

Mark Roethof
Tera Patron
Tera Patron

Hi There,

Do you perhaps have a bit more info on how your logic looks like? I just did a very small test, works fine. With both a Bot Response Script Output to generate the card (with the code you posted) and a Bot Response Card. The only difference in the script is I used a vaInputs instead of a vaVars, but I don't reckon this would be the difference.

Kind regards,
Mark

find_real_file.png

find_real_file.png

find_real_file.png

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Kamer Taj
Mega Expert

Hi Mark,

i have same issue.when iam giving reference fields for selected table its not populating.

below is my script:

(function execute() {
var html = '';
var gr = newGlideRecord('task');
if (gr.get(vaVars.sys_id)) {
var tableName = gr.getValue('sys_class_name');

if(tableName=='sc_task'){
var fieldList = ['requested_for','short_description','request_item','state','due_date','sys_updated_on'];
}
 
elseif(tableName=='rm_story'){
var fieldList = ['short_description','u_opened_for','priority','state','release','sprint'];
}
 
elseif(tableName=='idea'){
var fieldList = ['submitter','u_requester','u_sponsor','state','u_t_shirt_size'];
}
 
else
var fieldList = ['short_description','priority','due_date','sys_updated_on'];
 
var cardRenderer = new global.VaRecordCardRenderer(true);

var title = {
url: gs.getProperty('glide.servlet.uri') + '/' + tableName +
'.do?sys_id=' + vaVars.sys_id,
label: gr.getValue('number')
};
var fields = cardRenderer.createFields(fieldList, gr);
var lastComment = cardRenderer.createField('comments', gr, null, cardRenderer.getLastComment(tableName, vaVars.sys_id));
fields.push(lastComment);
html = cardRenderer.renderCard(title, fields);
}

return html;
})()