↓ Skip to main content
An ink and watercolour drawing of an open wooden tool tray on a workbench, with twelve compartments in three rows of four. Eleven hold one small part each: a key, a spring, a gear, a screw, a bell, a hook, a binder clip, a horseshoe magnet, a small bottle, a paper tag and a pencil. The compartment at the front right is empty.

Every Implicit Variable, Launch Point by Launch Point

Maximo Automation Scripts - This article is part of a series.
Part 4: This Article
An implicit variable is one that Manage puts into the script without being asked. Which ones a script gets depends on what started it. This page lists them, launch point by launch point, and names the rows of IBM’s own tables that are wrong.

The previous article showed the variables that you declare. This one shows the others. Keep it open while you write a script: most surprises with implicit variables come from expecting one that this kind of launch point never gets.

We checked IBM’s two tables of implicit variables against the behaviour of Manage in the MAS 9.2 series. Where a table and Manage disagree, this page follows Manage. The variables of integration, REST and the other special script types belong to their own articles later in this series.

What every run gets
#

Two variables are there on almost every run:

  • service, the helper object for errors, logging and calls to other scripts. Each run gets a new one.
  • scriptName, the name of the running script. Launch points, library calls and cron tasks set it. A script called through the REST API does not get it: on our test system, such a run failed with a NameError. service.getScriptName() gives the name in every run.

Every launch point adds launchPoint, its own name. And when the run has a record to work on, Manage adds the record and a few facts about it:

VariableWhat it holds
mbothe record the script works on
mbonamethe name of its object, for example WORKORDER
appthe application that opened the record; empty when no application did
userthe user ID of the session; a script cannot change it
interactivetrue in a user session, false in the background
onaddtrue for a new record
onupdatetrue for an existing record that will be saved
ondeletetrue for a record that will be deleted

One variable is missing here although IBM’s table lists it for all launch points: userInfo. Object, attribute, action and condition launch points do not get it. In those scripts, use mbo.getUserInfo().

Object launch points
#

An object launch point gets the list above for the init, app validate and save events. Its events differ in one point: whether there is a record at all.

  • Init, app validate, add, update and delete get mbo. There is no mboset variable. Reach the set through mbo.getThisMboSet().
  • Allow create (“can add”) gets only mboset, the set the new record would join. There is no mbo, and so no onadd, onupdate or ondelete either.
  • The setup and execute events of a non-persistent object get mboset. In setup, mbo is empty.

Attribute launch points
#

An attribute launch point gets the common list, with mbo as the record that owns the field. It adds the field itself:

VariableWhat it holds
mbovaluethe field’s value object, with methods such as getString()
mboattrthe field name, in lower case
the field name in lower case, for example statusthe current value
status_previousthe value before the change
status_initialthe value when the record was loaded

The last two names come from the field, whatever your own variables are called. A variable wostatus bound to STATUS gets no wostatus_previous; the previous value is in status_previous.

The events of an attribute launch point add their own variables:

  • Retrieve list gets lookupname and applink. The script answers with listWhere, listOrder, domainid, relationObject and relationWhere, and with srcKeys and targetKeys. Article 9 of this series covers lookups.
  • Initialize value reads thisvalue after the run and puts it into the field.
  • Initialize access restriction reads thisvalue_required, thisvalue_readonly and thisvalue_hidden after the run. Only true and false count there.

Action launch points
#

An action launch point is called by a workflow, an escalation or a button. It gets the common list, with mbo as the record the action works on, and adds:

  • scriptHome, the same record as mbo.
  • action, the name of the action.
  • params, the parameters of the action call.
  • wfinstance, the workflow instance, only when a workflow started the action.

params has a second use: the parameters of an error message, see below. In an action script it already holds the action’s parameters when the script starts, so set it to your own list before you raise an error through errorkey.

Custom condition launch points
#

A custom condition gets the common list and one more variable: evalresult. It starts empty, and the script must set it to true or false. A condition script that leaves it empty fails. Manage has no default of false.

Cron task scripts
#

A script started by the script cron task has no record, so there is no mbo. It gets:

  • arg, the text of the cron task’s SCRIPTARG parameter. Convert it yourself, for example with int(arg).
  • runAsUserInfo, the user the cron task runs as. Note the capital A.
  • instanceName, the cron task and its instance, as CRONTASKNAME.INSTANCENAME.
  • scriptName and service.

An error in the script is logged, and the cron task keeps running.

Variables that come with a declared variable
#

Each declared variable that is bound to a field brings a few more, named after the variable with a suffix. For a variable siteid:

VariableWhat it holdsCan the script change it?
siteid_requiredthe required flag of the fieldyes, if siteid is OUT or INOUT
siteid_readonlythe read-only flagyes, if siteid is OUT or INOUT
siteid_hiddenthe hidden flagyes, if siteid is OUT or INOUT
siteid_modifiedwhether the field was changedno
siteid_initialthe value when the record was loadedno
siteid_internalthe internal value, for a synonym domain onlyno

Four details matter in practice:

  • The flags change only for OUT and INOUT. For an IN variable, siteid_readonly = True has no effect. After save and after commit, nothing is written back at all.
  • Hidden also means read-only. Setting siteid_hidden = True also makes the field read-only, and setting it to false also clears read-only.
  • siteid_initial is no plain value. It holds a Maximo value object, so a comparison with a text is always false. Use str(siteid_initial).
  • These variables exist only for field bindings. A variable bound to a MAXVAR, a system property or a fixed value gets none.

What Manage reads after the run
#

Some variables flow the other way. The script sets them, and Manage reads them when the script has ended.

  • errorgroup, errorkey and params raise an error with a message from the message table, when both group and key are set. service.error(group, key) does the same at once and is the better choice.
  • warngroup, warnkey and warnparams add a warning to the record’s set, and the run continues. Neither IBM page names them. Pass warnparams as a list: a Java string array is replaced by params, which we saw on our test system.
  • evalresult, in a custom condition.
  • The retrieve list and initialize variables above, in an attribute launch point.

Thirteen names are reserved. The Automation Scripts application refuses a declared variable called app, errorgroup, errorkey, evalresult, params, user, launchPoint, scriptName, mboname, mbo, onadd, onupdate or ondelete. Other implicit names, such as service or interactive, are not reserved. Avoid them anyway, because a declared variable of the same name hides the implicit one.

What IBM’s tables get wrong
#

Six rows of IBM’s two tables are wrong for the 9.2 series:

VariableIBM’s tableWhat Manage does
userInfoall launch pointsnone of the four launch point kinds
mbovaluea user info objectthe field’s value object
onupdatethe record is inserted or createdthe record exists and will be saved
srcKeys, targetKeyssource is the current recordswapped: targetKeys name the fields of the current record
var_initiala value of the field’s typea Maximo value object
var_previousnamed after the declared variablenamed after the field, in lower case

The cron task page also writes runasUserInfo with a small a, and the async job page names a variable where that is called whereclause. Article 33 of this series collects the corrections that matter most.

What comes next
#

Article 5 covers the Variables tab: bindings, flags, and the traps in between.

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

The complete inventory of what the script engine does without documentation 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 4: This Article