To add a global variable to a codeunit, use the following procedure.
To add a global variable
-
Select the C/AL Editor, click View, and then click C/AL Globals.
Note For more information about how to open the C/AL Editor, see How to: Modify an Existing Codeunit.
-
In the C/AL Globals window, click the Variables tab.
-
Enter a name and select a data type.
If the data type that you select corresponds to an application object, you must also select a subtype, that is, the name of a specific object in the database.
If you select OCX or Automation, you must add a subtype. For more information, see Extending Microsoft Dynamics NAV Using COM.
If you select text or code, you must define a length for the variable. The default length is 10 characters for code and 30 characters for text.