Hi everyone,
I've created two EventSubscribers in a codeunit and I would like to use the global variable for these EventSubscribers.
The variable is define in first EventSubscriber but when code is working on second EventSubscriber. The variable is cleared.
There is any to shared the global variable for each EventSubscriber?
Example code for this scenario.
Codeunit 50000
var
varGlobalVariable: Text;
EventSubscriber 1
varGlobalVariable := 'a';
EventSubscriber 2
Record.Value = varGlobalVariable;
varGlobalVariable in EventSubscriber 2 is blank when the code is working on it.
EventSubscriber 1 and EventSubscriber 2 are in the same standard function.
Thank you.
Answers
Thank you JJMC, I've already tried your solution and it's work.
But, I wonder what side effects will have to be careful about this property?.
In fact, Microsoft refactoritation for the new versions, changed a lot of functions with this property if they have subscriptions so it is faster, because they start first time you invoque and they remain in memory until you quit the season that invoque them.
Thank you for your answer