How to get variables from main in global handler

I cannot get the variable from main in global handler. I’d like to use that variable value in my global handler Send SMTP Mail Message activity.
This is what I put in Subject >>
“SO header is not created.”+errorInfo.Variables(SO_header_c_CustOrderNo).ToString


Hi @Sein_Lai_Hnin,

You could make customer order no as argument and get it inside the global handler.

Hello @Sein_Lai_Hnin , Use arguments to pass the value from one flow to another flow
Kindly refer to this Thread, you may get some idea

You can pass the SO_header_c_CustOrderNo in the Argument.

In the Global Handler workflow → Create an New Argument

Regards
Gokul

I try creating argument in main and importing that argument in global handler but it becomes never ending loop. Main executed, got error so it goes to global handler, first activity in global handler is invoke workflow, workflow in invoke workflow is main, main executed, got error so it goes to global handler, first activity in global handler is invoke workflow, workflow in invoke workflow is main… it never goes to the next activity in global handler after invoke workflow which is Send SMTP Mail Message

If there is an error in Main and it goes to global handler, why do you need to invoke main in the global handler? The failure is likely to occur again and this will continue as a loop. Do you want to do the retry scope instead? ( in order to try the transaction in main multiple times?)

I used the invoke workflow in global handler because I needed arguments to import from main.
For retry scope, I don’t really need to try the transaction in main multiple times. I just need the variables from main in global handler coz in global handler, an error email is sent out so I need to put the variable value from main in that error email.

Hi @Sein_Lai_Hnin , Ok got it. If you are throwing the error explicitly from main then you can simply add the SO_header_c_CustOrderNo as part of the error message of the throw activity. Eg. :

new System.Exception("SO header is not created " +SO_header_c_CustOrderNo .ToString)

This will be available to you as part of the error message in the Global exception handler. Can you do this?

I cannot. Seems like global handler cannot just take variable from main like that.

Please try with try catch block.In try use invoke workflow.if exception occurs catch it in catch block and send email

This code was to be used in main to throw the exception explicitly. Can you try this in main itself and throw the exception with the required value ( i.e. the code given above?)

Did this work for you @Sein_Lai_Hnin