Search code examples
webspherejythonmaximo

Implicit variables are not defined in automation scripts


Upon creation of a automation script in IBM Control Desk / Maximo an array of implicit variables are created, according to the IBM docs:

Implicit variables are variables that you do not define. These variables are automatically provided by the framework. Some implicit variables are valid only when associated with a declared variable while others are not associated with any other variables.

In addition to implicit variables, a Maximo® business object (MBO) is also available to every script. You refer to the current business object by using the mbo reserved word.

From these docs:

https://www.ibm.com/support/knowledgecenter/SSANHD_7.6.0/com.ibm.mbs.doc/autoscript/r_variables_automation_scripts.html

When trying to use mbo with the following code inside a newly created Automation Script with no launch point:

mboSet = mbo.getThisMboSet()

I get the following error message:

NameError: name 'mbo' is not defined

This seems strange to me as mbo is a implicit variable that should be accessible.

I am new to Maximo and don't have enough experience to debug this problem at this point. How would I acces the mbo variable and use it? Thanks in advance.


Solution

  • mbo represents a single psdi.mbo.Mbo from a single psdi.mbo.MboSet (see the JavaDocs), or synonymously a single row from a single table. The Launch Point is what chooses the record to send to your script as mbo.

    If you run your automation script directly, via the Test button or by restoring the Execute button, which table and which row from that table should Maximo randomly choose to pass to your script as mbo? The answer to that rhetorical question is "none" -- Maximo should not randomly choose some record from some table but should not define mbo in such cases. Hence, the error is expected behaviour in the situation you presented.

    If you want your script to be able to run directly as well as from a launch point, you can check if "mbo" not in locals(): and then set up mbo for yourself. I have dubbed such automation scripts as "On Demand Autoscripts", and I use them regularly. If you spend some quality time with the JavaDocs, you might get there, too!