Key not present in dictionary

Hi, i am getting an error :
image
image

Could you pls help me how to resolve this?
TIA

HI @Cuberoot

Check out the reference video

Regards
Gokul

I have checked it but didn’t get the solution

This video is for reference @Cuberoot

Can you share the condition in the If activity

1 Like

image

Hi @Cuberoot

dict_master_sheets.Keys will give you the array of keys… add this in for loop in argument

dict_master_sheets.keys.ToArray

Then loop will iterate through all the keys

cheers

Sorry, i didn’t get it. Could you pls explain it in detail

Hi @Cuberoot

Have you assign Dict_master_sheet("Yoursheet") = Yes or No something like this. If you not assigned this it will throw this error.

Let say your

sheetname = test 

Yourstring = "No"

For the above case you need to assign like one in the image

Regards
gokul

Hi @Cuberoot

Instead of strArrTOC_1 use dict_master_sheets.keys.ToArray

Hope this clarifies

cheers

But you don’t know what his process is. Maybe he doesn’t want to loop through the keys, but through only certain ones based on the value of strArrTOC_1

1 Like

You have a value in strArrTOC_1 that doesn’t exist as a key in Dict_mast_sheets

That’s the reason for the error.

@postwick

That is what I mentioned first this is to loop through all keys

The next one was a clarification for the follow up question

cheers

So,how to rectify it

HI @Cuberoot

Can you show what you saving in strarrtoc_1 …the value that you saved there is not present in the dictionary that you are referring to

cheers

Find out why you have a value in strArrTOC_1 that doesn’t exist in Dict_mast_sheets

This is a problem with your logic, with your code. You have to figure out how you’re populating both of them and why the values don’t match. Or maybe the value not matching is an expected possible result and you have to first check if the key exists, before checking its value. It all depends on your process and the logic you need to use.

ok,thanks for your reply