MicroStrategy ONE

Procedures in Command Manager

Command Manager procedures are reusable scripts that can be executed from other scripts. You can reuse procedures with different input values, so that the procedure performs the same task in a slightly different way. Procedures can use Command Manager syntax, or they can be written in the Java programming language and incorporate Command Manager statements in Java commands.

For example, you can create a procedure called NewUser that creates a user and adds the user to groups. You can then call this procedure from another Command Manager script, supplying the name of the user and the groups. To use the procedure to create a user named KHuang and add the user to the group Customers, use the following syntax:

Copy
EXECUTE PROCEDURE "NewUser" ("KHuang", "Customers");

where NewUser is the name of the procedure, and KHuang and Customers are the inputs to the procedure.

Procedures are available only for use with project sources. Procedures cannot be used with Narrowcast Server statements.

Command Manager contains many sample procedures that you can view and modify. These are stored in the following Command Manager directory: \Outlines\Procedure_Outlines\Sample_Procedures\

For instructions on how to use procedures, see the Command Manager Help.

Using Java in Command Manager Procedures

Java is a simple yet powerful programming language that is widely used in the software industry. Java can be integrated into Command Manager procedures to automate repetitive tasks such as creating multiple users, or recursively listing all the folders in a project. Java is supported in Command Manager out-of-the-box; no additional software must be installed to execute Java commands.

To include Java in a Command Manager script, you write a procedure containing the Java code, and execute the procedure from a Command Manager script. Java cannot be included directly in a Command Manager script. For detailed instructions on using Java in procedures, see the Command Manager Help. (From within the Command Manager graphical interface, press F1.)

Java is supported only in procedures, and procedures are supported only with project sources. Java commands cannot be used in scripts to be executed against a Narrowcast Server metadata.

Do not use the System.exit command to exit a procedure. This command terminates the entire Command Manager process.

Command Manager provides two special commands that can be used by Java scripts to execute Command Manager commands:

  • execute runs any Command Manager command, but it does not return the results.
  • executeCapture runs any Command Manager command and returns the results in a ResultSet object. This object behaves like a standard ResultSet object in Java: you can iterate through the results and retrieve individual items, which can then be used to extract properties of the results. This enables you to use the results elsewhere in the procedure.

For a detailed list of the ResultSet columns used in each Command Manager LIST statement, see the statement syntax guide for that statement in the Command Manager Help.