Hi community,
I have a data table with similar data as shown below:
Now I wish to store each value from column2 into a variable with name as mentioned in column1.
Please help.
Hi community,
I have a data table with similar data as shown below:
Now I wish to store each value from column2 into a variable with name as mentioned in column1.
Please help.
Use a dictionary type variable…and then can assign the key as the name and value as the Score
create variable dict of type Dictionary(string,String) and initialize it in a Assign activity using dict = Dictionary(Of String,String)
Then use a for loop on datatable and then use assign inside
dict(currentrow("Name").ToString) = Currentrow("Score").ToString
Hope this helps
cheers
Welcome to UiPath community!
I agree with @Anil_G approach that suits for your requirement.
Few Point to Add
When you are creating a variable of type dictionary Select System.Collections.Generic.Dictionary(String,String)
Also, at the end if you want to see the Rahul score that was stored in the dictionary then take message box and use below exp
Your Dic var name("Rahul")
Below workflow for your ref
SampleProcess.zip (3.1 KB)
Thank you @Anil_G and @ushu for your responses. Its working fine.
I was able to create dictionary with key as names but for my scenario i wanted out arguments. For eg: I want to Rohit’s score as out_RohitScore and use it in some other workflow.
Please help and let me know if i am not able to make myself clear about problem statement.
PS: the values in the table above are not static the number of rows might increase or decrease. So for one scenario score of 5 player could be there in Data table and in second scenario only 3 player’s score could be there.
But the problem statement stands same in need to create out argument like out_player’sName which will contain its score and send to other workflow.
So basically dynamically creation of argument is required. Please help.
Dynamically creating arguments is not possible…as if you just analyze…even if you create an argument there is no way it will know which variable or which argument the value is to be given to…that is the reason we go with dictionary
As you said…if you want to pass the value only for only one person then from the dictionary take only one key and pass the value dict("PlayerName").ToString
…the value would be assigned to same argument but depending on the player you select it would change the value it holds
or if you want all players then pass the dictionary in the argument…
Hope this helps
cheers
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.