I found some issue working with the global variables. The case is-
Global Variables : $$ControlAccountCodeDigitsLength = 2
Note: Initialize in the script, working with the app startup
The field having code digits: Code (Type, Number)
The field needs to get the calculation result: ResultCode (Type, Calculation)
Find the attached image to check the calculation
I need to get the result 0 or 1 if the Code Field has 2 or 4 digit code but dealing with the globals it is returning only 0. And I am also storing the calculated value because of the field ResultCode is a related field.