Dictionary: Asking to initialize before using dictionary


#1

Scenario: Dictionary

Steps to reproduce: Getting an error : Initialize before using the dictionary

Current Behavior: How to initialize

Expected Behavior:

Studio/Robot/Orchestrator Version: Studio Trial, 2016.2.6344

Last stable behavior:
Last stable version:
OS Version: windows 7
Others if Relevant: (workflow, logs, .net version, service pack, etc):


#2

Hey @shakahamed

Before adding items to the dictionary it must be initialized. The default value of the Dictionary object is Nothing.

To initialize it you can use an Assign activity or define default value in the Variables pane.

The value should be new Dictionary(Of String, String) if both your key and value are strings .

Regards…!!
Aksh


#3

Hi @aksh1yadav ,

I am trying to get the unique value from the Data table using the dictionary. This is the first time using the dictionary option. Am i using the correct one?

Regards,
Shakeer N


#4

Hi,

This seems to work, but how can I initialize a dictionary of Integers and Strings?
I tried these statements with a variable that is of type Dictionary<Int32,String>:

New Dictionary (Of Integer, String) from {{1,2},{“one”, “two”}}

AND

New Dictionary (Of Int32, String) from {{1,2},{“one”, “two”}}

But both statements only give the following error:
Option Strict On disallows implicit conversions from ‘Integer’ to 'String’
Option Strict On disallows implicit conversions from ‘String’ to ‘Integer’

I’m not sure what’s wrong.

Regards,
RPA_tester


#5

Hey @RPA_tester

Here you are using integer and string then here key will be of INT type and value will be of String type.

Use this -

New Dictionary(Of Int32,String) From {{1,"test"},{2,"test2"}}

For your understanding a sample workflow i am attaching.

Rpa_Tester_Sample_Dictionary_int_string.xaml (5.6 KB)

Regards…!!
Aksh


#6

Thanks, seems to work.

BR,
RPA_Tester