Add and configure a code item
- Last UpdatedApr 07, 2025
- 3 minute read
Although you can create a code item in any folder in the project, we recommend that you store your code items in a central Code folder under the System Configuration folder.
To create a code folder
-
Right-click System Configuration, point to Add Item, then Standard Items, then select Applications Folder. A new ApplicationsFolder appears.
-
Rename the folder to Code.

To create a code item
-
Right-click the Code folder, point to Add Item, then Standard Items, then select Code. A new Code item appears.

-
Rename the code item. This is the name to use when the code item is referred to from elsewhere in the project.
-
In the Properties pane, set the CompileAction property to None before you start writing code for the item. Setting the CompileAction property to None stops the code item from being compiled and made available in the project.
Property
Description
Valid values
CompileAction
Specify whether the code item compiles or does not compile into the project. Use this property to disable the compile action when you are writing code-in-progress or you want to save an incomplete item.
None, Compile
Also, code that does not compile cannot be saved to Server, so if you want to save code that cannot be compiled, set the CompileAction property to None before you attempt to save the project.
Note: Any references to the methods written in a code item which has its CompileAction property set to None cause a compile error in the item that makes the reference. For example, if a Calculated Variable item expression element refers to the method in a code item, and the code item has its CompileAction property set to None, the Calculated Variable item generates a compile error because the method it references is not available to the compiler.
-
Double-click the Code item in the Project Explorer hierarchy to open the Code window. The document window displays in the Multiple Document Interface (MDI) background area of Studio.
-
Type your C# code directly into the Code window.

Any code you enter the Code window must comply with the C# coding considerations.
-
When you have written some code, save the project while the CompileAction property is still set to None. This stops unfinished code from being compiled and made available throughout the project. However, it enables you to save the unfinished code.
An unsaved code item displays with an appended asterisk (*) to the item name in the titlebar of in the Code Editor window. The asterisk is removed from the name when the code item is saved successfully.
-
When the code is final, change the CompileAction property to Compile.
-
Save the project. If the CompileAction property is set to Compile when the project is saved, this verifies that the code item contains valid C# code syntax and compiles.
If the compile does not succeed, you are informed that the project did not save. To determine why your code item won't compile, see Troubleshoot a code item.