We checked IBM’s testing pages against the behaviour of Manage in the MAS 9.2 series. Where the pages and Manage disagree, this page follows Manage.
The Test Script dialog#
Open the script and choose Test Script. You can pick a launch point; without a choice, the test uses the script’s first one. The dialog prepares a record, runs the script, and shows two results:
- Data: the record after the test, as JSON when “test with JSON” is on, otherwise as XML.
- Process Log: the output of
service.logandservice.logError, ofprint, and the message of an error. Thelog_infostyle methods still go to the log file, as article 14 explains.
The object path#
The object path tells the test which record to use:
| Path | Record |
|---|---|
ASSET[assetnum='11430'] | the first asset that the where clause finds |
ASSET | a new asset when the launch point adds records; otherwise the first asset in the table |
PO[ponum='1056']/POLINE | a new line under that purchase order: a part after a slash is a relationship |
The launch point decides between new and existing. An event that only adds records makes the test add one. An update or delete event makes it load one. A where clause together with a new record is refused.
The Set Attribute Value table puts values on the record before the run. For the launch point’s own field, the test sets the value twice: first with the event’s own checks switched off, then again with no flag.
What a test changes#
This part decides whether a test is safe on a system with real data:
- Save events are rolled back. The test runs the save in a transaction, writes to the database without a commit, and rolls back.
- After commit is the exception. For an after commit launch point, the test saves the set, and that commits. The data is changed for real.
- Integration tests are rolled back. Inbound files, invoke channels and the exits run in a transaction that the test rolls back.
- An action test skips the action’s security check. A test can pass where a real user would be refused.
- A script that saves for itself still commits. The rollback covers the record’s transaction. A set that the script opens and saves on its own commits, test or no test. Article 15 explains why.
What each script type needs#
| Script type | Input in the dialog | Note |
|---|---|---|
| Object and attribute events | an object path, attribute values | for can delete, the test calls delete on the record |
| Attribute init and lookups | an object path | the test reads the field, or asks for its list |
OBJECT.NEW and OBJECT.DUPLICATE | an object path | .NEW forces a new record; .DUPLICATE copies the record |
| Inbound object structure | an XML or JSON file | runs through the structure’s service, rolled back |
| Outbound object structure | an object path | the record is serialized through the structure |
| Query and action scripts | a where clause, sqp: parameters | the action’s security check is off |
| Channels and services | a file, an external system | an enterprise service test needs the external system |
| Endpoint and REST scripts | type ENDPOINT or RESTAPI, a file or parameters | a REST test uses POST unless you choose another method |
| Condition | a plain where clause | the result is thrown away; log it to see it |
| Action | an object path | the launch point name is passed as the action |
| Role | an object path, OBJECT[where] | a plain where clause fails |
| MXERR | group and key from the name | both can be changed in the dialog |
| Formula | one row per parameter | the test evaluates NAME(p0,p1) as a formula |
| Cron task | type CRONTASK, an object path | the path arrives as arg |
Two of these hide their answer. A condition test runs the script and discards evalresult, so add
a service.log line with the result. And a role test reads its path like an object test, so
assetnum = '11430' alone fails; write ASSET[assetnum='11430'].
One switch is easy to miss: setup logic of a non-persistent object needs the system property
mxe.script.callsetuponinit set to 1. It is a run-time switch, so it also changes behaviour outside
tests.
A second way: through the REST script handler#
The dialog is a screen. For tests that a command line or a pipeline can repeat, we used another way
in this series: a test script without a launch point, called through /maximo/api/script/<NAME>.
Article 22 shows the handler.
Such a driver script opens a record, hands it to the script under test as a library call, and returns what it sees as JSON:
from java.util import HashMap
from com.ibm.json.java import JSONObject
assets = service.getMboSet("ASSET", userInfo)
try:
assets.setWhere("assetnum = '11430' and siteid = 'BEDFORD'")
asset = assets.moveFirst()
ctx = HashMap()
ctx.put("mbo", asset)
service.invokeScript("ASSET_SAVE_SETPRIORITY", ctx)
result = JSONObject()
result.put("priority", asset.getString("priority"))
responseBody = result.serialize()
finally:
assets.cleanup()ASSET_SAVE_SETPRIORITY stands for the script under test. The driver never saves, and the clean-up
drops every change. The record reaches the script under test through the mbo entry of the map, as
article 13 shows.
Two limits apply. The script under test runs without its launch point, so launch point variables are missing. And the same rule as above holds: a script that saves its own sets commits them.
What IBM’s pages get wrong here#
| Topic | IBM’s pages | What Manage does |
|---|---|---|
ASSET alone | makes a new asset | only when the launch point adds records; otherwise loads the first asset |
| The Process Log | shows all logs that use service | only service.log, service.logError, print and the error message |
| The enterprise service example | SYNC.MXITEMINTERFACE.EXTEXITIN | the name needs the dot: EXTEXIT.IN |
| The condition test | shows True or False | the result is thrown away |
| The role test | a plain where clause | needs the OBJECT[where] form |
Article 33 of this series collects the corrections that matter most.
What comes next#
Article 31 covers debugging scripts and the warnings framework.
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.
