↓ Skip to main content
An ink and watercolour drawing of a tall wooden post on a workbench, with five small bells hanging from short arms at five heights, alternating left and right, each with a pull cord. The second bell from the top swings to the side, with motion lines beside it; the other four hang still.

Object Launch Points: Every Event and Where It Fires

Maximo Automation Scripts - This article is part of a series.
Part 6: This Article
An object launch point runs a script when something happens to a record. Manage offers five event types for it, and each one fires at its own moment, with its own data. This article shows when each event fires, the order of one save, and the cases in which an event never fires at all.

This is the first article of Part 2 of our series on automation scripts. Part 1 covered the foundations; the overview lists every part. We checked IBM’s pages about object launch points against the behaviour of Manage in the MAS 9.2 series. Where the two disagree, this page follows Manage.

Five event types, one per launch point
#

An object launch point has exactly one event type. Only the save type combines events: it can run on add, on update and on delete, in one context.

Event typeWhen it firesThe script getsTypical use
Initializeevery time a record is loaded or createdmbodefaults, calculated fields, field flags
Validate applicationwhenever the record is validated, also at the start of every savembochecks before anything is written
Allow creationbefore a new record is added to a setmboset, no mborefuse a new record
Allow deletionwhen someone deletes a record, before it is markedmborefuse a delete
Savewhen the record is saved: on add, update or deletembologic tied to the save, see below

So one launch point cannot run on initialize and on save. For that, create two launch points for the same script.

Initialize
#

The initialize event fires for every record that Manage loads from the database, and for every new record. It runs after the object’s own initialization code. It is the place for defaults, calculated fields, and fields that become read-only, required or hidden.

It also fires very often. A list of work orders loads many records, and the script runs once for each of them. Keep an initialize script short.

Validate application
#

The validate application event fires whenever the record is validated as a whole. A save does that first, so the event also fires at the start of every save. The script runs before the object’s own validation code.

This makes it the right place for checks that must hold before anything is written. In a save, it runs before every other script of the object.

Allow creation and allow deletion
#

These two events decide whether a record may be added or deleted at all.

  • Allow creation runs before the new record exists. The script has no mbo, only mboset, the set that the new record would join. Its owner, mboset.getOwner(), is the record above it, for example the PO when a PO line is added.
  • Allow deletion runs when someone deletes a record, before Manage marks it for delete. The script has mbo, and ondelete is still false at this moment.

The initialize event is too late to refuse a new record, because the record is already in the set by then. Use allow creation for that.

Save
#

The save type runs on add, on update and on delete. A record in a save goes to exactly one of the three. Delete wins over add, and add wins over update. Each save launch point also has a context: before save, after save or after commit. Article 7 of this series shows how to choose.

What an error does depends on the context:

  • Before save: the save stops, and the transaction is rolled back.
  • After save: the database has run the SQL, and the transaction is rolled back.
  • After commit: the data is already committed. Manage writes the error to the log, and the user sees nothing.

After save and after commit, Manage writes no OUT or INOUT variable back to the record.

The order of one save
#

When a user saves a record, the events and the object’s own code run in a fixed order:

The order of one save, from validation to the after commit scripts The order of one save, from validation to the after commit scripts
The order of one save, from validation to the after commit scripts

Two points in this order matter for design:

  • A before save script runs after the object’s own save code. Values that the script sets still go into the SQL, but the object’s code has already made its own decisions.
  • Validate application runs first. A check there sees the record before any save logic has changed it.

When an event does not fire
#

Four cases surprise people, because the script is configured and still does not run, or another script runs in its place.

  • Allow creation and allow deletion can be bypassed. Code that adds or deletes a record with the access check switched off skips both scripts. A delete of a new record that was never saved skips allow deletion as well.
  • Only one allow creation script runs per object. You can define two launch points for it, and Manage keeps only one: the last one by script name and launch point name. The other is silently ignored, and the conflict warning does not report it. The same holds for allow deletion.
  • A launch point condition is ignored where there is no record. Allow creation has no mbo, so a condition on it is never tested, and the script always runs.
  • An inactive launch point has no listener. It does not fire until you activate it again.

Non-persistent objects
#

A non-persistent object, such as the object behind the change status dialog, never reaches the database. Its launch points work differently:

  • A save launch point on add or update fires when the dialog’s set is executed. The script gets mboset. The context does not matter here: before save, after save and after commit all mean “on execute”.
  • An initialize launch point can also fire once when the dialog is set up, before its records exist. This is off by default. The system property mxe.script.callsetuponinit set to 1 switches it on. The script then sees onsetup as true, mbo as empty, and fills the set through mboset.

The setup call has two limits. An error in a setup script is only written to the log, so service.error never reaches the user there. And for one non-persistent object, only one setup script runs.

What IBM’s pages get wrong here
#

TopicIBM’s pagesWhat Manage does
Combining eventsone launch point can listen to several eventsone event type per launch point; only save combines add, update and delete
Allow creationonly one launch point can be definedyou can define more; the last one silently wins
Allow creation and deletionthey always decide whether a record can be added or deletedcode that switches the access check off skips them
On deletethe page describes it as an update eventit fires for records marked for delete
Examplesthe init and allow deletion examplesthey use true and !, which Jython does not know; write True and not

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

What comes next
#

Article 7 picks the moment: before save, after save or after commit, and what each one costs.

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 6: This Article