Creating multiple dictionaries

Hello,

I am trying to create a dictionary using assign activity. It works fine the first time but when I use it for another dataframe I am getting an error
Main has thrown an exception

Source: Dictionary EC

Message: An item with the same key has already been added.

@MAHESH1 @arivu96 @Dominic

@jamnanin

The keys should be unique, You can’t add duplicate values to Keys. Better check before adding whether the dictionary is having the the current key value.

Regards
Mahesh

Hi @jamnanin,
If the Key is already present in the dictionary this error will occur.

You can check if condition before adding into dictionary.
dict.ContainsKey(keyName)

Regards,
Arivu

do you mean to say the dictionary shoudl not contain keys with the same name? because the column i use to make the dictionary doesnt have duplicate values.

@arivu96 but how will I know which key is same? because the column i use for making this dictionary has all unique values only

@jamnanin
The Keys should not contains Duplicate values.

Regards,
Mahesh

I doesnt… all the keys are unique

Hi @jamnanin,

Before assign check the value are already exists in the Dictionary
dict.ContainsKey(keyName)

True-> key already exists
Else-> you can add the key into Dictionary

Regards,
Arivu

You can overwrite existing key values with the Assign activity, but you just can’t add a new key with an existing key. So you can only do the Add part one time.

but I am making a new dictionary all together. with all unique key values. I still get this error

@jamnanin

How you are making new dictionary.
From Where you are taking values to add into the Dictionary.

Regards,
Mahesh