Script Structure and Basics
As with all scripts, the script file itself should be placed in the scripts folder under /Agiloft/data/[kb name]/scripts. To run the script a script action should be created with the name of the script file as the action name. The script action checks to see if the file exists in the proper location when it is saved.
To use the ALget and ALset functions they must be imported from the modules. All of the Agiloft sample scripts start with importing just these functions. The standard sys module should also be imported.
The rest of the script can consist of a single function unless other references are needed. The Agiloft sample scripts define a single function called 'action' and calls that function at the end.
The Agiloft python scripts are always called with 2 arguments: an XML file representing the current and former record states, and a second XML file for the version of the records which should be saved to the database when the script is complete.
The following lines are required to generate XML at the end of the script:
A normal Agiloft python script involves reading values, history, and user data from the input file and saving any changes to the output file.
The first step in dealing with these files is to load them into Python objects that can be later referenced.
The sample scripts and examples assume the scripts are structured this way and refer to “input” and “out” when using ALget and ALset.