The object launch points of article 6 react to a record. An attribute launch point reacts to one field of it. The fifth event, retrieve list, drives lookups and gets its own article next. We checked IBM’s pages against the behaviour of Manage in the MAS 9.2 series. Where the two disagree, this page follows Manage.
How an attribute launch point attaches#
An attribute launch point does not watch the field all the time. It registers on the object’s initialize event. Each time a record of that object is initialized, the launch point attaches itself to the one field of that record. From then on, the field runs the script like any of its own rules.
| Event | When it runs | Typical use |
|---|---|---|
| Validate | when the field gets a new value | check the new value |
| Run action | when the field gets a new value, after all validations | change other fields |
| Initialize value | once, on the first read or write of the field | set a value |
| Initialize access restriction | once, on the first check of the field’s flags | make it read-only, required or hidden |
Each launch point has one of these events. For two events on one field, create two launch points.
Validate and action#
When a field gets a new value, Manage runs two rounds. First every validation of the field runs: the built-in ones and every validate script. Then every action runs: the built-in ones and every action script.
This order gives a clear rule for splitting the work:
- Checks go into validate. An error there refuses the new value, and no action of the field runs.
- Consequences go into action. An action runs only when every validation has passed, so it can rely on a valid value.
One script can also do both in one launch point, and IBM’s own example does. The two-launch-point split is easier to read and to switch off separately.
Two cases skip the rounds:
- An unchanged value runs nothing. Setting a field to the value it already has calls no script.
- Code can switch the rounds off. When code sets a field with the flag that suppresses validation, the validate scripts do not run. The flag that suppresses actions skips the action scripts. A delayed validation postpones both.
What the script sees#
The script gets the record as mbo and the field under its own name in lower case. For a launch
point on PURCHASEPRICE, the new value is in purchaseprice. Two more variables come with it:
purchaseprice_previousis the value right before this change. After a second change to the same record, it is the value of the first change.purchaseprice_initialis the value when the record was loaded.
There is no mboset variable. Use mbo.getThisMboSet() when you need the set.
A calculated field that stays right#
The difference between _previous and _initial matters for running totals. Suppose an asset
keeps the total quantity of its spare parts in a field, and each spare part line has a quantity.
An action launch point on the spare part’s quantity can keep the total right:
- The script variable
totalis INOUT and bound to&owner&.sparepartqty, the field on the asset that owns the spare part. - The script adds the change:
total = total + quantity - quantity_previous.
quantity_previous is the right choice here. It holds the value before this change, so a user who
changes the same line twice adds only the difference each time. quantity_initial would count the
first change twice.
When the target field is read-only#
A script that sets a read-only field fails with an access error. That happens often with calculated fields, which are usually read-only on purpose. There are two fixes:
- For a variable: tick Suppress Access Control on the variable. Manage then writes the value past the read-only check.
- For code: pass the access check flag when you set the value, as in
mbo.setValue("SPAREPARTQTY", total, MboConstants.NOACCESSCHECK).
Suppress Access Control skips only the read-only check. Validations and actions of the target field still run, unless you suppress them too. Article 5 covers the three flags.
Initialize value and initialize access restriction#
The two initialize events of an attribute launch point run just in time. Manage calls them once per field and record, the first time something needs the field:
- Initialize value runs on the first read or write of the value. The script sets
thisvalue, and Manage puts it into the field. That value counts as the field’s initial value, and the record does not count as modified. - Initialize access restriction runs on the first check of the field’s flags. The script sets
thisvalue_readonly,thisvalue_requiredorthisvalue_hiddento true or false.
thisvalue works one way only. Manage reads it after the run, and never fills it before, so the
current value is in the variable named after the field. For a yes/no field, set thisvalue to 1 or
0: the value true fails.
The just-in-time design saves work. An initialize script on the object would run for every record that is loaded, whether the field is used or not. The attribute version runs only when the field is needed.
The case in which they never run#
The launch point attaches to the field during the object’s initialize event, after the object’s own initialization code. If that code already read the field’s value or checked its flags, the field counts as initialized. The attribute script then never runs for that record.
So when an initialize value or access restriction script works on one object and stays silent on another, look at the object’s own initialization first. An object launch point on initialize is the fallback, at the cost described above.
What IBM’s pages get wrong here#
| Topic | IBM’s pages | What Manage does |
|---|---|---|
mboset | the script has access to the set | no mboset variable; use mbo.getThisMboSet() |
_previous | the value at the record’s initialization | the value right before this change; the value at load is _initial |
thisvalue | represents the field | written by the script, read by Manage, never filled before the run |
| API example for the vendor | sets the read-only flag | the variable version sets required; the API version needs the required flag to match |
| Initialize value example | reads the field site | most objects call it SITEID |
Article 33 of this series collects the corrections that matter most.
What comes next#
Article 9 covers the fifth event: lookups from a script with retrieve list.
IBM’s own pages are the reference to keep next to this series:
- Automation scripts in the IBM Maximo Manage documentation.
- All about Maximo scripting, IBM’s scripting guide on GitHub.
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.
