Dynamic Choice Input In VA.

pandeyved
Tera Contributor

Hi all,

I need help in one use case. In Virtual agent we need to provide user a option to select which will come dynamically from the table.
Detail:
We are showing some topics from Employee Center in our Virtual Agent and As We have connected content for the topics, so we need to display all the connected content from the topics which is available in portal. But instead of statically defining the catalogs mapped to the particular topic we need to show directly from the table. How can we achieve this?

I am writing this code in VA Script in Dynamic choice Input:

(function execute() {
var options = [];
var hardwareContent = new GlideRecord("m2m_connected_content");
hardwareContent.addEncodedQuery("topic.parent_topic=891e85b01b5ab550134bddf59b4bcb9b^catalog_item!=NULL");
hardwareContent.query();
while(hardwareContent.next())
{
options.push(hardwareContent.catalog_item.getDisplayValue());
}
return options;
})()
But My chat bot returning I have technical Issue. Kindly Guide

Thanks
Vedant

6 REPLIES 6

Anil Lande
Kilo Patron

Hi @pandeyved 

Considering your encoded query is correct, you need to change the script like below:

(function execute() {
var options = [];
var hardwareContent = new GlideRecord("m2m_connected_content");
hardwareContent.addEncodedQuery("topic.parent_topic=891e85b01b5ab550134bddf59b4bcb9b^catalog_item!=NULL");
hardwareContent.query();
while(hardwareContent.next())
{
            options.push({ 'value': hardwareContent.catalog_item.getUniqueValue(), 'label': hardwareContent.getDisplayValue('catalog_item') });
}
return options;
})()

 

test your topic and let us know what error you are getting

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Check below link for more details.

https://docs.servicenow.com/bundle/vancouver-servicenow-platform/page/administer/virtual-agent/refer...

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi @Anil Lande 
Thanks for the help, but After using this still I am getting this error:

pandeyved_0-1704430415259.png

Can you please support

So what is the logs telling you? Usually when getting this message, most of the times valuable information is written to the logs.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn