Virtual Agent: Getting the user selection for "Reference Choice List" user input?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 12:30 PM
I'm populating a reference choice which is outputting the options to the end user:
Name | Value
End Chat end_chat
Live Agent live_agent
The list shows up fine, but I need to find out what the user selection is so I can use my decision tree accordingly.
You can see in my two attachments how the activity is setup.I'm logging the following:
You can see I selected the "End Chat" option in the window, but it's logging the last entry when I do
var selection = vaInputs.chat_action_ref.getValue();
gs.info("Chat Action selection: " + selection);
How can I get/store the option the user has chosen?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2019 02:53 AM
Hi huntj06,
I had a similar problem. I needed the value of user input to send it over through REST method. In my case, I get always the first value.
You need to assign the value in separate script action block and it`s better to use global value. So try to add "Script Action" right after the "Reference choice" (as showed on below screen).
Before that add script variable (in this example "options").
In "Script action" code assign user input from "Reference choice" to this variable:
vaVars.options = vaInputs.chat_action_ref; //I`m not using getValue(), it`s working without it
Correct user input should be in "vaVars.options". After that, you can use it later in the code.
I hope that will work for you too.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2019 08:59 AM
Good Afternoon,
Nice little tip but do you know how to return the sys_id instead? if I use "getDisplayValue();" then it returns the name of the person, if I don't use anything then I get nothing at all.
i.e.
var options = [];
var gr = newGlideRecord(table);
gr.addQuery('name','CONTAINS',vaInputs.employee_name);
gr.setLimit(15);
gr.query();
while(gr.next()) {
options.push({ 'value': gr.getValue('name') + " - " + gr.getValue('email')});
}
return options;
All I am doing is a user search to log a request, a list of names display, they click on the correct name and then I am trying to use that when creating a new Request to populate the Requested For field.
Wondering if I need to push the sys_id into the array as well but don't want that displayed in the list shown.
Any suggestions and I would be grateful
Kind Regards
Ashley
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2019 04:36 AM
Not to worry, figured it out in the end
Kind Regards
Ashley
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2020 10:08 PM
Try
var selection = vaInputs.chat_action_ref.getValue('sys_id');