We checked IBM’s pages against the behaviour of Manage in the MAS 9.2 series, and we read the warning rules and the scan schedule on our test system. Where the pages and Manage disagree, this page follows Manage.
Three ways a script fails#
It does not save#
Manage compiles a script when you save it. A syntax error refuses the save with BMXAA7836E, “The script did not compile”. The typical causes are language level: newer Python or JavaScript syntax that the engines in Manage do not accept. Article 2 lists what each engine refuses.
It stops with an error#
A run that fails shows a message of this shape. One of our own test scripts produced it, here with the script renamed:
BMXAA7837E - An error occured that prevented the MYSCRIPT script for the null launch
point from running. java.lang.ClassNotFoundException: ... in <script> at line number 22The message carries three useful facts: the script name, the launch point (null when the script
ran without one, as through the REST API), and the line number in the script. The part in the
middle is the error that Java or Python raised.
Two traps in Jython made our own test scripts fail this way:
except Exceptionmisses Java errors. A Java exception, such as a class that is not found, is outside Python’s exception tree. Catchjava.lang.Throwablewhen a Java call may fail.globals()can end the request. In a script called through the REST API, a call toglobals()ended the request with BMXAA1649E, a NullPointerException. To test whether a name exists, useeval(name)and catchNameError.
It does nothing and says nothing#
These cases raise no error at all:
| Case | What happens |
|---|---|
| The script is inactive | it is skipped; a REST call answers HTTP 200 with an empty body |
| A cron task script fails | the error is logged, and the cron task run counts as done |
| An after commit script fails | the error is logged; the user sees a successful save |
| A function of a callback script is missing | it is skipped |
| A callback script lacks the function flag | the body runs once, and no function is called |
| An MXERR script fails | the error is printed to the console, and the message stays as it was |
For these, the log is the only witness. Set the script’s own Log Level to DEBUG, and Manage writes the launch point, every variable value and the run time. Article 14 shows how. To repeat a failing case, article 30 shows two ways to test.
The warnings framework#
Manage can scan scripts for patterns that cause trouble. The scan is a cron task, SCRIPTWARN. On
our test system it was active and ran every 12 hours as MAXADMIN, and it had stored 366 warnings for
89 active scripts.
How the scan behaves:
- It scans compiled scripts only. A script that failed to compile is never scanned.
- Comments count, unless they start the line. A line is skipped only when
#or//stands in the first column. An indented comment is scanned, and a match there counts. - Line numbers can be lower than in the editor, because skipped lines are not counted.
- Patterns are text. The scan does not parse the code, so a match inside a string or a trailing comment counts too.
- Warnings stay until you resolve them. The scan never removes or reopens a warning. A fixed script keeps its old warnings until someone sets Resolved, with a resolution text.
The rules, as we found them#
The rules are data, so a system can differ. These were active on our test system:
| Code | What it flags | Note |
|---|---|---|
| BMXAA10015W | a save() call | only in scripts with an object or attribute launch point |
| BMXAA10018W | loading the Mozilla compatibility script | JavaScript only |
| BMXAA10019W | an object init launch point | for every such launch point, active or not |
| BMXAA10022W | several scripts on one launch point event | never fires |
| BMXAA10023W, BMXAA10024W | print | the first for JavaScript, the second for Jython |
| BMXAA10025W | an assignment to errorkey | use service.error |
| BMXAA10027W | = MXServer() | a server object built by hand |
| BMXAA10028W | a set from getMboSet(name, userInfo) without cleanup() | counts lines; three-argument calls are not counted |
| BMXAA10030W | an assignment to warnkey | not in IBM’s table |
| BMXAA10039W | a Manage service created by hand | not in IBM’s table |
| BMXAA10041W | more database connections taken than freed | not in IBM’s table |
Two gaps matter:
- The conflict warning BMXAA10022W never fires. The check that should find several scripts on one event can never report one, and it looks only at the launch points of the one script it scans. Article 29 shows how to get a real order instead.
- The
count()warning BMXAA10026W was missing. IBM’s table lists it, and our test system had no rule for it. The check class meant for it could never warn anyway.
So a script without warnings is not proven clean. The scan catches patterns, and two of its promises are empty.
What IBM’s pages get wrong here#
| Topic | IBM’s pages | What Manage does |
|---|---|---|
| The conflict warning | flags several scripts on one event | never fires |
The count() warning | flags count() in loops | no rule on our test system; its check could never warn |
| The save warning | flags save calls | only in scripts with an object or attribute launch point |
| The rule table | lists the warning codes | three more active rules exist |
Article 33 of this series collects the corrections that matter most.
What comes next#
Article 32 covers writing automation scripts in TypeScript.
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.
