How to store two values in a single variable for each loop?

Hi Everyone!

Could I know for my case how to allow my variable (PaymentMethod) to store all the possible input options array (selectedItems: Cash, BankTransfer and Cheque)?

The loop in the following picture allows me to have more than one possible payment method, just depends on my selection (perhaps 1, 2 or 3). However, the variable could only save the last payment method that I have selected. Are there any other ways for me to save all the answers in one single variable to rely on for the Filter DataTable activity afterwards?

Here is the picture of drafted activities:

Many thanks indeed.

image

Hi @kit2815

If your using list variable you have to initialize like this

Your_List_variable=new List(of string)(new string(){“Cash", “BankTransfer”,"Cheque”})

If your using Array variable You have to initialize like this
Your_Array_Variable={“Cash", “BankTransfer”,"Cheque”}

Or else if you want display multiple choices in input dialog , you can directly enter values like this


image

Hope it solves your issue

Update us whether you got your desired solution or not

Thanks,
Robin

Hi @kit2815 ,

Based on my understanding, initialize an array variable and store the values by appending them into the array variable.
Then, as @Robinnavinraj_S said, use that variable in the Input options array field.

Thanks,
@90s_Developer

Hi @Robinnavinraj_S

Many thanks for your warm reply, but it is not the solution.

My robot actually included both array and list variable as you have mentioned while simply using input dialog to display multiple choices are not applicable in my case, because I might have to choose more than one answer in each run. However, using the current activities, the variable could only save the last answer that I have selected…

Hi @90s_Developer

Thanks for your reply as well.

I am using this approach actually but the variable still only shows the last payment method that I have chosen only. For example, If I choose Cash for the first time and choose BankTransfer between the remaining two options for the second time, the variable could only store the value of BankTransfer as a result.

As of my understanding

finally you want all the choices you have chosen ?? right?

if it is so

append the current chosen value into list variable

ListVariable= ListVariable.Append(Currentvalue)

finally list variable contains all the values you have chosen

Hi @Robinnavinraj_S

Sorry for the late reply.

Yes, I want all the choices that I have chosen to save in a variable.

Would you mind further explain or demonstrate the following language:
ListVariable= ListVariable.Append(Currentvalue)

Is it worked in the assign activity and where should I place this activity in my flowchart?

Many thanks.

Hi i think it should be on Assign activity

ListVariable : left side
ListVariable.Append(Currentvalue)** : Right Side

ListVariable= ListVariable.Append(Currentvalue)

Hi @Ahmad_Rais

May I know the “Currentvalue” is a new variable that I should create or is it another existing variable? As the system said it is not declared. Thanks!

Hi @kit2815
current value is output variable from input dialog

Hi @Robinnavinraj_S
Thanks but there is an error that occurred as follow. Is there something wrong with the variable type?

We have to initialize list variable

Put the below syntax in the deafult value tab of your list variable in variables panel

New List(Of String())

hi i think @Robinnavinraj_S is right
try this


this is might be what @Robinnavinraj_S means

1 Like