Dynamic choice input in Virtual Agent

ShaidaC
Tera Expert

Hi Everyone,
I am trying to build a Custom topic in virtual agent. I have a static choice and then based on the static choice there will be dynamic choice values. However I am not able to do so. Also I am not able to check logs as well for the script inside virtual agent

ShaidaC_0-1766494380665.pngShaidaC_1-1766494401234.png

ShaidaC_2-1766494413464.png

Script for dynamic choices:


function execute() {
gs.info('virtual agent script running');
var options = [];
var cat = vaInputs.category; // Category node ka variable name

// agar category nahi aayi
if (!cat) {
return options;
}

// lookup table se subcategory lao
var gr = new GlideRecord('u_hr_category_subcategory_lookup');
gr.addQuery('u_active', true);
gr.addQuery('u_category', cat);
gr.query();
gs.info("helloqwerty");

while (gr.next()) {
options.push({
value: gr.getValue('u_subcategory'),
label: gr.getValue('u_subcategory'),
render_style: 'data'
});
}

return options;
}

Can anyone please help me achieve this
1 REPLY 1

Bshirisha
Tera Contributor

Hi @ShaidaC ,

Are the static category choice values same as u_category values in u_hr_category_subcategory_lookup?