Develop > Tailoring > Advanced functions > Scripting > Executing scripts

Executing scripts

After you have created your forms and the script definitions to display them, you must decide how you want to execute the script. You have several choices:

  • Incident Management (using profile records)
  • Display option (from within an application)
  • Format Control
  • Stored query

Access the scripts file

You can access the scripts file using one of the following methods:

  • Menu button
  • Database Manager

Executing a script from Incident Management

Profile records within Incident Management allow you to specify the script to execute when a user opens a new incident record. You can design a script that displays forms containing only those fields necessary for recording the particulars of an incident. For example, if the technician taking the call selects hw.network as the incident category, a condition statement in the script exits to a panel that displays a network hardware related form. When the script finishes, the record carrying all the necessary information is created and the technician is ready to work on another issue.

Executing a script from displayoption

Use a displayoption to create a button, the Options menu and the Context menu selections on a Service Manager form from which to execute your script. For information on the Display application, see the related topics.

Executing a script from Format Control

Scripting can be called from the routines process of Format Control. It is important to place the script call as the last item on the routine call list when executing a script from Format Control.

Executing a script from a stored query

A script executed from a stored query searches for records by allowing the user to select precise search parameters. The Service Manager standard system contains an inactive script that can execute from a stored query to display a list of key words relating to previous incidents. The stored query then uses the key word selected to search for similar incidents.

This stored query runs from an open incident record using either Format Control or a displayoption (Screen ID: apm.edit.problem). In this example, a displayoption has been created that adds an option called Probable Cause to the More Actions menu of an open incident record. This option runs the stored query called probcause.user.

The stored query, probcause.user, executes the script called probcause.user.1.

The script probcause.user.1 has a single panel that displays the probcause.user.1 form. The condition for exit (null($key.words)) requires the user to choose a key word before allowing the script to exit.

Important: Scripts executed from stored queries typically set values into the same fields used by the query to retrieve records. In this example, the common field is key.words.

The script is executed before the form from the query (probable.cause.user) opens. The form opened by the script is called probcause.user.1 and supplies the query form with a key word for searching.

When the user selects a key word and clicks OK, the script exits. The stored query then uses the key word to search the probcause file for matching entries. If more than one match is found, the system displays a record list of possible causes for your incident.

Click a selection to view the details with the probable.cause.user form. When you have finished viewing all the choices, click Cancel to return to the incident record.