Beginning of Chapter Next Chapter

10.15.3. Scripts

10.15.3.1. Script Editor

xTuple ERP supports QtScript, a tool for loading UI forms using ECMAScript based language files for creating and modifying application functionality without the need to recompile. To take advantage of this functionality, one should have a basic understanding of how to program using ECMAScript and create UI screens using QtDesigner.

Note

To learn more about scripting for xTuple ERP, please see the Scripting Guide.

To view the master list of available scripts, select the "Scripts" option. The following screen will appear:

Scripts Master List

The scripts master list displays information on all stored scripts, including script name, description, order, and enabled status.

To the far right of the screen, the following buttons are available:

CLOSE

Closes the screen, returning you to the application desktop.

NEW

Opens screen for adding a new script to the scripts master list.

EDIT

Enables you to edit highlighted scripts. The edit screen is the same as that for creating a new script—except that when editing, the fields will contain script information.

DELETE

Highlight a script and then select this button to remove the script from the master list.

10.15.3.1. Script Editor

To create a new script, select the NEW button. The following screen will appear:

Create New Script

When creating a new script, you are presented with the following options:

Name

Enter a name to identify the script. The name of the script must match the name of the screen the script will be used for. If the script name does not match the screen name, the script will not be used. Because a single screen may require more than one script, you may save multiple scripts having the same name. The order, notes, and content of each script will distinguish one from the other.

Notes

Enter a brief description of the script.

Order

Specify the order in which the script should be run. The script having the lowest number (i.e., "0") will be run first, and then following scripts will be run in consecutive order.

Enabled

Select to enable the script. If not selected, the script will be disabled. A disabled script will not be run when the corresponding screen is executed.

Script

Enter the content of the script using QtScript. You may type the script directly into this window, or you may import a script using the IMPORT SCRIPT button.

To the far right of the screen, the following buttons are available:

CANCEL

Closes the screen without saving any changes.

SAVE

Saves the script and adds it to the scripts master list.

IMPORT SCRIPT

Select to import a script from your local file system into the database. This option is useful if you prefer to do your scripting using an external script editor. The script you import will be shown in the script window.

Warning

Every time you import a script file, the new script will replace the script which was shown in the script window previously.

EXPORT SCRIPT

Select to export the script shown in the script window to your local file system. You would use this option if you need or want to edit the script and do not have a copy stored locally on your system. Once exported, the script can be edited using an external editor—and then re-imported into the database using the import option. Whenever you import a script file, it automatically replaces whatever script was in place before it.