Issue with "Dynamic choice" in Virtual agent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2024 01:09 PM
I want to create a 'Dynamic Choice' in the Virtual Agent to display a list based on the values in the Category field.
To achieve this, I have queried the sys_choice table with the following conditions.
So that I should get the below option for Category.
I have added the below code snippet in my script:
But in my Virtual Agent, I am seeing other options that are not based on the query I provided.
Could someone please help me with this.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 07:59 AM
@bondita1 - Were you able to figure this out?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 09:07 AM
For anyone else having this issue, it has to do with the filter on the query. Instead of 'table = incident' it should instead be 'name = incident'.
EX:
(function execute() {
var options = [];
var gr = new GlideRecord('sys_choice');
gr.addQuery('inactive', 'false');
gr.addQuery('name', 'incident');
gr.addQuery('element','category');
gr.query();
while(gr.next()) {
options.push({ 'value': gr.getUniqueValue(), 'label': gr.getValue('label') });
}
return options;
})()