Page tree
Skip to end of metadata
Go to start of metadata

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.

import sys
# interface modules to interact with input and output xml files
from ALget import ALget
from ALset import ALset

 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.

def action(inputXMLFile, outputXMLFile):
	function parts here
.
.
.
action(sys.argv[1], sys.argv[2])

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.

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.

# Load input into internal structures. This is required step before
# accessing input by API calls.
	input = ALget(inputXMLFile)
	out = ALset(outputXMLFile)

The sample scripts and examples assume the scripts are structured this way and refer to “input” and “out” when using ALget and ALset.

CONTENTS