1

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.

Niek Jonkman
  • 1,014
  • 2
  • 13
  • 31

2 Answers2

3

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!

Preacher
  • 2,127
  • 1
  • 11
  • 25
  • Eek! The JavaDocs have gone missing! Follow [this question](https://stackoverflow.com/questions/66273744/documentation-for-maximo-api-is-unreachable) to see if they come back and where. – Preacher Feb 19 '21 at 15:11
  • You can also check using `if mbo is None:` instead of using `mbo not in locals():` – AhmedRana Jun 14 '22 at 12:44
  • @AhmedRana is not correct. `if mbo is None` will throw an error `if "mbo" not in locals()` The latter checks if the variable is defined in the local scope, while the former assumes it is and checks its value. – Preacher Jun 15 '22 at 15:05
  • I have used it numerous times without any error. May be not the best approach but worked everytime – AhmedRana Jun 16 '22 at 13:50
2

You say it's a newly created Automation Script with no launch point? How did the script actually run then to get that error? Did you press the test button? If so, that's the problem. The test doesn't run the script in context (where those variables can exist). You will need to create a launch point to trigger your script, then you should see the implicit variables come into play.

Dex
  • 1,241
  • 6
  • 13
  • I did press the test button indeed. When I have the time to test if a launch point can solve my problem, I will come back to you. – Niek Jonkman Feb 17 '21 at 08:13
  • I managed to get mbo's (without a launch point) by using MXServer and fetch, in my case, CI's. – Niek Jonkman Feb 19 '21 at 08:03
  • Yep. You can do a lot still with the test option or no launch point even (sometimes Maximo just requires a script to have a specific name for it to launch, no launch point), as Preacher points out. Your question was about the implicit variables specifically though, so that's what I addressed. – Dex Feb 19 '21 at 15:03