I am trying to put a try-catch around an assign activity for something which won’t necessarily need assigning. I’m scraping customer information from different pages of a website and sometimes the field ‘CompanyName’ doesn’t appear.
I read that if I put that inside a try-catch that it would skip over it if it is one of these instances where it doesn’t apply. However, I keep getting an error of ‘Assign: The given key was not present in the dictionary.’ and the catch not working.
Am I doing something wrong with it? Is there a specific exception type I should be selecting for this? On the ‘finally’ section section, I’ve made it so that CompanyName gets assigned to ‘No Company Name’ instead, but this doesn’t work either.
I’m a bit stuck and would appreciate any input! Thank you.
This error means that you are referring to a dictionary key that does not exist. Check the naming conventions of your dictionary keys and ensure they match the source.
If you surround your Assign with a TryCatch, and then mark the Catch part as System.Exception, it will work as a “Catch-All” and any exception that the assign throws will be ignored
The error occurs as I’m scraping a data table and then using the dictionary make the entries into variables. Sometimes the entry isn’t present because the field isn’t there.
I just put the trycatch as a system.exception and I get the same error
Good morning @dr1992 !
Detecting an empty row can be done as you said, with either a
Or with the TryCatch.
As @william.coulson said, the exception will be System.Exception Type. But bear in mind that the Trycatch, if it is running in debug mode, it will always stop inside the try in case of an error. You can nevertheless, make it continue by pressing F5.
While running in normal mode, it will not stop, and it will proceed with your next activities!
Hi, can you share the workflow or at least a screenshot of it ?
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.