The given Key was not presnet in the dictionary

Hi

I am doing an exercise where I am convering various variables into a big string, putting this into an array, traversing through the values to replace any values ‘And’ with ‘&’ and then assigning this into a Dictionary so I can reference the value later on to place the value inside a word document.

I am only testing with 2 variables at the moment but I will be using around 10 hence why I want to convert my variables into some sort of data structure so I can use a for each loop to go through the values, modify them and then input them into my template.

So let’s say I have a bankName and AccountName variable where
Bank Name = Bank and West
Account Name = Mr and Mrs Smith

i convert these variables into an Array, traverse through the array, and then assign the Dictionary to the new formatted value.

However, when I try to print the value of the Dictionary it doesn’t work and says “The given key was not present in the Dictionary” just wondering what I am doing incorrectly and if anybody can help. For the purpose of this exercise we are not allowed to use while loops with array indexes hence why I am using a Dictionary.

Attached is the workflow
BlankProcess.zip (14.0 KB)

Thanks everyone

Hi,

In this case, It’s better to define key names of the dictionary in advance ,for example, as the following.

Main.xaml (8.3 KB)

Regards,

1 Like

Hey,
Use this workflow
BlankProcess.zip (2.3 KB)

Thanks
Rounak

I am still getting the same error saying the key does not exist when I try access the value outside the loop. Is there a way I can access each value outside the loop?

Sorry we are not able to use the ‘add to dictionary’ activity either

hey,
Then Use Assign Activity
to place the key and value in Dictionary

Thanks

Hi,

Did you run the attache xaml file in my previous post?
Can you share your current workflow as a file?

Regards,

Sorry - I recreated your workflow into mine but i made an error, it’s working fine now. Thank you very much!

1 Like

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