Virtual agent response variables

bart_huysmans
Kilo Sage
I am doing some testing to see how we could utilize virtual agent to give better feedback to end-user
Bellow some standard code that I update to get some variables data - how do you set the title for the variables.
 
Result.
 
find_real_file.png
 
 
Code.
 
(function execute() {

// Determine whether the card should show null value fields or not.
var skipNullValues = true;
 
var html = '';

// Query the requested item table and get the only requested item
var gr = new GlideRecord('sc_req_item');
gr.addQuery('active', true);
gr.addQuery('request.requested_for', vaInputs.user);
gr.addQuery('short_description','CONTAINS','Account Extension');
gr.setLimit(1);
gr.query();
if (gr.next()) {
var cardRenderer = new global.VaRecordCardRenderer(skipNullValues);

// Card title: A number hyperlink to the record
var title = {
url: vaVars.base_url + vaVars.service_portal_base_url + '?sys_id=' + gr.getUniqueValue() + '&view=sp&id=ticket&table=sc_req_item',
label: gr.getValue('number')
};

// Fields that would be shown on the card.
var fieldList = ['cat_item','variables.account_ext_requested_for','state', 'variables.KF_Account_Ext_For_Office', 'sys_updated_on'];
var fields = cardRenderer.createFields(fieldList, gr);

// Get the latest comment and add it on the card
var lastComment = cardRenderer.createField('comments', gr, null, cardRenderer.getLastComment('sc_req_item', gr.getUniqueValue()));
fields.push(lastComment);

// Get the card HTML
html = cardRenderer.renderCard(title, fields);
}
 
return html;
})()
1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Unfortunately, this is not possible with the out-of-the-box setup. Script Include "VaRecordCardRenderer" does amongst others:

fieldObject.value = value == null ? gr.getDisplayValue(field) : value;

Where the field you are entering, is touching the gr.getDisplayValue part. Obviously, you are not entering a field though a variable instead. I do understand what you are trying to achieve, though this will simply not work.

You will have to change the Script Include for this.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

View solution in original post

1 REPLY 1

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Unfortunately, this is not possible with the out-of-the-box setup. Script Include "VaRecordCardRenderer" does amongst others:

fieldObject.value = value == null ? gr.getDisplayValue(field) : value;

Where the field you are entering, is touching the gr.getDisplayValue part. Obviously, you are not entering a field though a variable instead. I do understand what you are trying to achieve, though this will simply not work.

You will have to change the Script Include for this.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn