Issue in selecting the output from dynamic choices

pandeyved
Tera Contributor

Hi All,
I am facing issue with one thing. In Virtual Agent I am using Dynamic Choice Input. Where I am writing this code to print choices, so Choices are printing successfully, but when the user is selecting any choices from it, then technical issue is coming.

var sysPropertyValue = gs.getProperty('x_4dai_va.connected_content_id');
var sysPropertyObject = JSON.parse(sysPropertyValue);
var topicSysId = sysPropertyObject[selectedCategory];
var options = [];
gs.info("line15"+topicSysId);
var grObj = new GlideRecordSecure("m2m_connected_content");
grObj.addEncodedQuery('catalog_item!=NULL^topic.parent_topic=' + topicSysId + '^catalog_item.active=true');
//gr.setLimit(5);
grObj.query();
while (grObj.next()) {
options.push({ 'value': grObj.getUniqueValue(), 'label': grObj.getDisplayValue('catalog_item') });
}
return options;

one more thing, at the place of topicSysId if we give any hardcoded sysid it is working fine.
In logs I checked selectedCategory is showing as undefined but it is defined in some other topics where I am giving values to selectedCategory, so why I will define here.

Kindly Guide
Thanks
7 REPLIES 7

@pandeyved 

where are you printing it when you are saying it's getting printed correctly? Is it on the earlier topic where it's created?

check this link

Pass variables between topics 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar 

I am printing it's value in next topic not in previous one, where I have defined it.

@pandeyved

check the link I shared above.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader