↓ Skip to main content
An ink and watercolour drawing of one small teal machine on a wooden workbench, with an orange gear behind a round hatch. Two long levers with orange knobs are fixed to it, one on each side, and a rose paper tag hangs from each. The left lever is pulled down with motion lines beside it, and the right lever stands upright.

Scripts, Launch Points and Variables: How the Pieces Fit

Maximo Automation Scripts - This article is part of a series.
Part 3: This Article
A script holds the code, and a launch point decides when that code runs and with which data. Once you see where each setting lives, one script can serve many fields and objects. This article shows how the pieces divide the work.

The first article of this series named the three parts of a script: the script, the launch point and the variables. In practice, most questions are about the borders between them. Where does a binding belong? What does the launch point decide on its own? And why can a variable no longer be deleted?

We checked the answers against the behaviour of Manage in the MAS 9.2 series, and against IBM’s two documents about scripts. Where IBM’s text and Manage disagree, this page follows Manage.

What belongs to the script, and what to the launch point
#

Every setting lives in exactly one place. The script holds what is the same for every use. The launch point holds what is different for each use.

Lives on the scriptLives on the launch point
the source code and the languagethe target: an object, an attribute, an action or a condition
the active flag of the whole scriptthe event, for example before save or after commit
the variable namesa condition that decides whether the script runs at all
per variable: IN, OUT or INOUT, the type and the access flagsper variable: a different binding value, if you set one
per variable: the default bindingthe active flag of this one launch point

The last rows are the key to reuse. A variable is declared once, on the script. Each launch point starts with a copy of these variables. A launch point can then give a variable a different binding value, and that value wins for every run through this launch point.

The override changes only the binding value. Whether the variable is IN, OUT or INOUT, its type and its access flags always come from the script.

One script for two fields
#

A common rule: the target start date and the target finish date of a work order must not lie in the past. Two fields, one rule. You can write two scripts with the same code, or one script with two launch points. The second way needs one variable and one override.

One script, two attribute launch points, one variable bound two ways One script, two attribute launch points, one variable bound two ways
One script, two attribute launch points, one variable bound two ways

The setup, step by step:

  1. Create the script with one variable, checkdate. It is IN, and its binding is the attribute TARGSTARTDATE.
  2. Add an attribute launch point on WORKORDER.TARGSTARTDATE. It keeps the default binding.
  3. Add a second attribute launch point on WORKORDER.TARGCOMPDATE. On its variables, bind checkdate to TARGCOMPDATE.

The code never names a field:

from java.util import Date

# checkdate comes from the launch point: TARGSTARTDATE or TARGCOMPDATE
if checkdate is not None and checkdate.before(Date()):
    service.error("workorder", "datenotinpast")

A date field arrives in the script as a Java date, and an empty field arrives as None, so the check is short. The message workorder/datenotinpast is one you create yourself in the message table. Article 12 of this series covers errors and messages.

A third field is now one more launch point and one more override. The code stays as it is, and a fix to the rule is a fix in one place.

What the launch point decides at run time
#

The launch point does more than point at a field. Four of its settings change what happens when the script runs.

  • The condition. Manage evaluates the condition against the record before the script starts. When it is false, the script does not run at all. Two cases have no record to test: the “can add” event of an object launch point, and the callbacks of non-persistent objects. There the condition is ignored, and the script always runs.
  • The event. Each object launch point has one event context, for example before save, after save or after commit. After save and after commit, Manage writes no OUT or INOUT value back to the record. Only IN variables make sense there. An error raised by the script still works.
  • The kind of launch point. A custom condition launch point accepts only IN variables. Manage refuses an OUT or INOUT variable there.
  • The active flag. A launch point can be switched off on its own. For object and attribute launch points that stops the calls; the first article shows why action and condition launch points behave differently.

Plan the variables before the first launch point
#

Two rules lock a variable early, so it pays to decide the variables before you add launch points.

  • After the first save, the name of a variable, its binding type, its literal type and its Allow Override flag can no longer be changed.
  • Once the script has any launch point, no variable of the script can be deleted. It does not matter whether a launch point uses that variable.

So choose neutral names, such as checkdate instead of targstartdate. A name that describes the role keeps working when a second launch point binds it to another field.

Two more details belong here:

  • A variable bound to a MAXVAR or a system property is never written back to anything. The application does not force such a variable to IN, so you can declare it OUT. Then Manage does not even read the value in. Declare these variables as IN.
  • At run time, a binding on the launch point always wins. Manage does not look at the Allow Override flag there. Article 5 of this series covers this and the other traps of the Variables tab.

Scripts that need no launch point
#

Some scripts never get a launch point, and the variables then come from the caller. Later articles of this series cover each kind:

  • Library scripts, called by other scripts through service.invokeScript (article 13).
  • Scripts that Manage runs by name, such as WORKORDER.NEW (article 10).
  • Integration scripts, named after the integration point (article 18).
  • REST API scripts, called through their own URL (article 22).
  • Cron task scripts, started by the script cron task (article 26).

What IBM’s documents get wrong here
#

Three statements about variables are wrong or incomplete for the 9.2 series:

  • IBM: a variable cannot be deleted while a launch point refers to it. In fact, Manage blocks the delete as soon as the script has any launch point.
  • IBM: a launch point can override a binding when the script allows it. At run time, any binding on the launch point wins. The Allow Override flag is not checked there.
  • IBM: MAXVAR and system property variables are always IN. They are never written back, but nothing forces them to IN. Declared as OUT, they get no value at all.

Article 33 of this series collects the corrections that matter most.

What comes next
#

Article 4 lists every implicit variable, launch point by launch point. Article 5 covers the Variables tab and its traps.

IBM’s own pages are the reference to keep next to this series:

The complete list of corrections, with the evidence for each one, is in our member area. Members get access on request, so get in touch if you want it. If you want help with the scripts in your own Manage, our services page shows how we work.

IBM and Maximo are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide.

Maximo Automation Scripts - This article is part of a series.
Part 3: This Article