How to use an array to store multiple values for a reference field within virtual agent topics

Essa
Tera Contributor

Within my topic flow I have set a reference choice that allows a user within a chat to select one of the references field choices. The reference field within the form allows users to select multiple reference choices. 

 

1. First step I did was add the reference choice, then added a static choice so the user can select yes or no if they would like to add more references.

find_real_file.png

 

2. If the user selects 'yes' within the static choice it will then prompt for another reference field that would ask the user for the other reference they would like, then prompt again if they would like to add the reference again. if yes it uses a decision to go back to add another choice and if no it will finish the topic flow. 

find_real_file.png

 

My question is I am having issues getting all the reference choices that have been selected. I tried adding a script action to store the values of the references but ran into issues.

My main question is how can I use an array to store all the reference choices then once the incident is created it will show multiple references that a user has selected within the chat.

 

Also not sure if my logic is correct on setting two reference choice fields one for the first reference, and then if the user wants to select more it goes to another choice asking for the same question. 

 

2 REPLIES 2

Shavi Dabgotra
Giga Contributor

Hi,

Did you get any solution for this? I also want to store the value of reference choice. 

Thank you in Advance!

Guy10
Tera Contributor

Hi,

You should use the Script Variable to achieve it and update the 'script variable' in script action option. for example (name of the variable which need to be create is Role)

(function execute() {
vaVars.Role+=','+vaInputs.role_anodot;
})()
 
just notice that if you don't insert a default value to the variable - in the array the first value will be 'null'.