This article closes Part 5. We checked IBM’s pages against the behaviour of Manage in the MAS 9.2 series. Where the pages and Manage disagree, this page follows Manage.
From event to message#
The filter runs first, before the record is serialized. That makes it the cheapest place to drop an event. A channel processing rule could drop it too, but rules run on the serialized message, after that cost is spent.
The event filter#
The filter script is named PUBLISH.<CHANNEL>.EVENTFILTER, in upper case. It runs from the
channel’s default event filter class. A channel with its own Java filter class runs the script only
when that class calls the filter method of the default class. A class that replaces the method
without that call never runs the script.
The result goes in evalresult, and its meaning is the reverse of what the name suggests:
evalresult | Effect |
|---|---|
| True | the event is dropped |
| False | the event is published |
| not set | the default checks of the filter class decide |
Setting evalresult at all also switches off two default checks of the filter class: the check for
recurring events and the check for the record hierarchy. A script that sets it takes over the whole
decision.
# PUBLISH.MXWOINTERFACE.EVENTFILTER: publish only status changes to APPR
evalresult = True
if mbo.isModified("status") and mbo.getString("status") == "APPR":
evalresult = FalseThree more facts:
mbois the event record. IBM’s pages say a bug hidesmbohere and recommendservice.getMbo(). In the 9.2 series, both work.- The filter has no message.
irData,messageType,extSystemandconndo not exist here.ifaceName,osName,userInfoandinteractivedo. - Only event-based channels filter. A channel used for export has no listener, so no filter runs.
IBM’s best-practice page has a filter sample whose last line sets evalresult = True on every path,
so it drops every event. Put that assignment in an else, or set it first, as above.
Publish channel exits#
Article 18 lists the names, the order and the variables of the exits. Two points belong to publish channels.
An external exit can just change irData. When the script leaves erData empty, the changed
irData becomes the message. IBM’s asset example works this way.
Walking the children. IBM’s job plan example sets a description on each job task in a before user
exit. Its loop calls logger.info, but no variable logger exists, so the script fails with a
NameError. The IBM Docs copy also drops the last line, which leaves the last job task as the current
object. With service.log and the last line kept:
tasks = irData.getChildrenData("JOBTASK")
for i in range(tasks.size()):
irData.setAsCurrent(tasks.get(i))
irData.setCurrentData("DESCRIPTION", "Task " + str(i + 1))
service.log("job task " + str(i + 1) + " renamed")
irData.setParentAsCurrent()setAsCurrent with the child object works for XML and JSON channels. The other form,
setAsCurrent(list, index), works for XML only and fails for JSON.
A workflow after an inbound message#
An inbound object structure script can start a workflow once the message is saved. The function for
that is afterProcess, which runs once per message, after the save:
from psdi.server import MXServer
def afterProcess(ctx):
wo = ctx.getPrimaryMbo()
if wo.isNew() and wo.getString("status") == "WAPPR":
MXServer.getMXServer().lookup("WORKFLOW").initiateWorkflow("WOSTATUS", wo)The script is OSIN.MXWODETAIL, so it runs for a REST POST to that structure as well. Two details:
isNew()stays true after the save, so it still tells a new work order from an update.- With several nouns in one message,
ctx.getPrimaryMbo()returns the record of the last noun.
Inside the function, service does not exist. ctx offers its methods.
Scripted message-driven beans#
A message-driven bean can read messages from an external JMS queue and hand each one to a script.
IBM’s page shows the setup: a bean with the class psdi.iface.jms.JMSScriptListenerBean and an
env-entry named SCRIPTNAME. The script gets:
| Variable | Holds |
|---|---|
jmsmsg | the JMS message |
userInfo | the user the bean runs as |
mdbctx | the bean’s context |
Two facts decide whether messages survive:
- The script name must match exactly. The bean reads
SCRIPTNAMEonce, at start. Without an active script of exactly that name, it logs an error and returns. The message counts as received, and it is lost. - A script error keeps the message. An error marks the transaction for rollback, so the message comes back to the queue.
So activate and test the script before the bean starts reading. IBM’s page names only jmsmsg. The
IBM Docs copy of the bean’s XML stops before its closing tags.
What IBM’s pages get wrong here#
| Topic | IBM’s pages | What Manage does |
|---|---|---|
mbo in an event filter | hidden by a bug; use service.getMbo() | bound in the 9.2 series; both work |
| The filter example’s summary | drops events that did not change a work order to APPR | the example tests an asset for BROKEN |
| The best-practice filter sample | filters by status | sets True on every path and drops every event |
| The job task exit | logs with logger.info | no logger exists; NameError |
| The scripted MDB | only jmsmsg | also userInfo and mdbctx; a missing script loses the message |
Article 33 of this series collects the corrections that matter most.
What comes next#
This ends Part 5. Part 6 is about REST API scripts: your own endpoint, how to protect it, and the object structure actions and queries.
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.
