How to add data in key value pairs in Hashtable in UIPath?

Hi Team, I want to add data in hashtable(Key Value Pairs) in UIPath. Can anyone please help on this because I am getting errors while adding the data.

1 Like

In UiPath we use Dictionary to store Key Value
https://forum.uipath.com/t/dictionaries/23936

we can use a simple assign activity
like thiis
yourdicitionaryvariable(“yourkeyname”) = “yourvalue”
where dictionary variable is created in the variable panel like this
name = dict_input
type = system.Collections.Generic.Dictionary(string,string)
default value = New Dictionary(of string, string)

and may i know what was the issue you were getting
Cheers @Vikas1681

3 Likes

Hi create a Dictionary variable of type uipath.collections.generic.dictionary
Ex : Dict1
Since you already got a Datatable ex : DT1
Use for each row
Now inside for each row of DT1
Use ‘Get row item’ activity to get the values from the datatable

You need to use 2 get row item activities to fetch the values from 2 columns (to use them as key and value in the dictionary)

Now below to the get tow item activities use “add to dictionary” activity

Add properties
Key filed as variable output from 1st get row item and value field as variable output from get row item 2

Dictionary field value as Dict1

1 Like

Thanks Guys. It worked

Hi, please mark the topic as solved , so that other users can refer to the solution
Thank you
Happy Automation

Sure.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.