How to use the variables/arguments of Main workflow in Global Handler?

I searched the forum but didn’t find the answer. The most useful was this: Can we pass extra arguments to Global Exception Handler? but didn’t work. How can I consume the variables or arguments defined in Main workflow in Global Handler workflow?

Hi Amin,
please see this post for the solution:

It works fine by using errorinfo.variables(“your_Variable_from_main”).ToString in the global handler.
But only for variables (arguments need to be assigned to a string variable in main first to be able to use them). And only for strings…

1 Like

A short happy-note here: not only for strings. Here`s how you pull the queueitem when within Global Exception handler by simply casting the variable to its type (the variable was declared on the workflow/sequence that threw the exception).

(C#, not vb.net below)
(QueueItem) errorInfo.Variables[“item”]

Of course, always check for null before doing operations on the QueueItem within the Global Exception Handler.