Understanding Script Hooks

Script hooks are "locations" in the SmarTeam software where the software can be set up to execute a user-supplied script and pass parameters to it. Script hooks are provided for most standard SmarTeam operations. Three different stages of a SmarTeam operation are defined for script hooks: before the operation executes, after the operation executes or instead of the operation's execution. These three operation stages are represented by the software events: Before, After, and InsteadOf operation. Thus, you specify a script hook uniquely by the SmarTeam operation and the stage with which it is associated. Accordingly, in this guide, it is convenient to refer to a script hook by a name in the form EventName OperationName, for example, Before Update, After Check In or InsteadOf Add. Note that not all operations have script hooks defined for all three of the operation stages.

The purpose of the script is to allow you to intervene and modify the action of the standard SmarTeam operation. For example, if a script is attached to the Before Update script hook, the script is executed by SmarTeam before SmarTeam actually updates the attributes of the object in the database. Here, the script can change some of the attributes before they are written in the database. If a script is attached to the After Update script hook, it is executed after the attributes are already updated in the database. Here, the script might send notification of the successful update.

The following figure illustrates the Before Update hook for the Update Operation:

Link to scripts.gif