Skip to main content

Creating and Activating a Source Control Class

Creating and Activating a Source Control Class

This section describes the basic requirements for creating and activating a source control class.

Extending Studio

You can use either %Studio.Extension.BaseOpens in a new tab or %Studio.SourceControl.BaseOpens in a new tab to add a source code control menu to Studio. You can add up two menus with 19 menu items each.


Users must have the %Developer role in order to use the Studio source control menus.

The %Studio.Extension.BaseOpens in a new tab class provides the following methods, which all use the internal name of the InterSystems IRIS document:

  • Empty Login and Logout methods that you can implement as needed. The variable $username records the current user. (In the Login method, the Username argument is provided for backward compatibility; it is recommended that you use the variable $username instead.)

  • Basic methods to indicate the status of a given InterSystems IRIS document: GetStatus, and IsInSourceControl. Implement these methods as needed.

  • Callback methods that are executed when a user performs some action on an InterSystems IRIS document. These methods include OnBeforeLoad, OnAfterLoad, OnBeforeCompile, OnAfterCompile, ItemIconState.


Studio class compilation can use multiple processes. Therefore, do not use properties of %Studio.Extension.BaseOpens in a new tab to pass information from MenuItem to OnBeforeCompile. Instead, use a temporary global.

%Studio.SourceControl.BaseOpens in a new tab is a subclass of %Studio.Extension.BaseOpens in a new tab and provides the following additional elements:

  • An XDATA block named Menu that defines an additional menu for InterSystems IRIS: Source Control. By default, this menu contains the menu items Check In, Check Out, Undo Check Out, Get Latest, and Add To Source Control. This XDATA block also defines additional menu items for the context menu in Studio.

    All these menu items call methods also defined in this class.

  • Methods named CheckIn, CheckOut, UndoCheckOut, GetLatest, and AddToSourceControl, which do nothing by default.

To extend InterSystems IRIS, you define a new class that extends one of these classes. As you see in “Activating a Source Control Class,” the Management Portal provides a way to indicate which extension class is currently active in a given namespace. If an extension class is active in a given namespace, and if that class defines an XDATA menu block, those menu items are added to InterSystems IRIS.

Creating a Source Control Class

To create a source control class, do the following:

  1. Create a subclass of %Studio.Extension.BaseOpens in a new tab or %Studio.SourceControl.BaseOpens in a new tab.

  2. If you started with %Studio.Extension.BaseOpens in a new tab, create an XDATA block named Menu in your subclass. (Copy and paste from %Studio.SourceControl.BaseOpens in a new tab to start this.)

  3. Implement the methods of this class as needed: AddToSourceControl, CheckIn, CheckOut, and so on. These methods would typically do the following, at a minimum:

    • If appropriate, import or export the InterSystems IRIS document to XML.

    • Call the appropriate function or method of your source control software, to act on the XML file.

    • Update internal information in InterSystems IRIS about the status of the given file.

    • Control whether the InterSystems IRIS document is editable.

    The details depend upon the source control system.

  4. Implement the GetStatus method of your source control class. This is required. You might also need to implement the IsInSourceControl method, if the default implementation is not suitable.

Activating a Source Control Class

To activate a source control class for a given namespace, do the following:

  1. Use the Management Portal to specify which extension class, if any, InterSystems IRIS should use for a given namespace. To specify the class to use:

    1. Select System Administration > Configuration > Additional Settings > Source Control.

    2. On the left, select the namespace to which this setting should apply.

    3. Select the name of the extension class to use and select OK.

      This list includes all compiled subclasses of %Studio.Extension.BaseOpens in a new tab in the selected namespace.

  2. If Studio is currently open, close it and reopen it, or switch to another namespace and then switch back.

The Management Portal Production Configuration Page also supports source control, see “Configuring Source Control Settings”.

FeedbackOpens in a new tab