Hi experts!
I am wondering if there are any recommendations about using global variables in single instance codeunits in Business Central. Generally, in modern object oriented programming defining and using global variablies should be avoided at all costs.
Are there any official guidelines for BC?
Here is an example where it is really tempting to use single instance codeunit global variables: I am using two subscribers - OnValidate Qty on Warehouse Receipt Line (1) and OnValidate Qty on Purchase Line (2).
(1) should update values on both Warehouse Receipt Line and on Purchase Line.
(2) should update only values on Purchase Line.
The problem is that when I call (1), it triggers my code in subscriber (2) - I don't want to do that. I don't have a handled boolean here in parameters, as those are standard OnValidate triggers.
What is the best approach? Is using single instance codeunit global variables a no-go here?