Testing Automation Scripts with the new Maximo 7.6 “Testscript” method (Part 1: MBO based scripts)

Maximo introduced with Version 7.6 a new feature which allows you to test your automation scripts in context of a new or an existing Mbo as well as in context of the Maximo Integration Framework (MIF). The downside of that new function is, that I currently have not found any good documentation and that some features like the object path syntax are not self explaining. In this two part series I would like to introduce the new “Testscript” feature and explain how easy it is to use for your daily script testing. In part 1 we will cover the test of scripts in context of a Mbo and in part two I will show you how to test in context of the MIF.

The old styled “Run Script” testing is no longer visible but can be enabled again using the trick in my other post.

The first thing to mention if you want to test a script with the new Mbo-Test functionality is, that you need to have a script with an Object Launchpoint. Scripts with attribute launchpoints are not tested, or even worse if you have both: an object launch point and a attribute launch point on the same Mbo always the object script runs, even you select the attribute launch point script! (Might be confusing!). On the the other hand side you could utilize an Object Launchpoint testscript to set a certain attribute in a Mbo which then triggers the attribute launchpoint as well 😉

Now lets create a very simple script with an object launch point for the ASSET object like the following:

print "Hello World"
print mbo.getString("ASSETNUM")

Press the “Test Script” button and you will see the following dialog:

At the top you will see information about the script and the selected Launchpoint we are running on.

With 1. you will select if we want the script to be tested against a newly created object or and existing object.

In 2. an object path can be specified if we want to reference an existing object. The format I currently found out is:

<OBJECT>[<SQL-WHERE>]

Examples could be:

ASSET[ASSETNUM='11200']
ASSET[ASSETNUM like '11%']
ASSET[ISRUNNING = 1]
ITEM[ITEMNUM='0815']

Important to remember, that you always get only a single resulting record to your script. This is the default behavior for an object script, where the resulting set is stored in the implicit Launchpoint variable mbo.

If you select Existing Object and specify an Object Path (remember to copy the Object Path to the clipboard – you have to reenter it for every test!) you can press the Test button.

You might see a result as follows:

  1. Data contains the resulting MBO in XML format.
  2. Log contains the output of the Print statements of the script.

With the Set attribute values section you can specify attributes which are overwritten from the original result. This is a nice feature when you need some testing data with certain specification (e.G. We need an asset in status of not running (ISRUNNING = 0), so we just need to specify:

So far we just have discussed the Existing Object path. If you like to create a New Object this also can be done with the testing function. The testing function basically calls an mboSet.addAtEnd() function to append a new record to the given MboSet. With the usage of Set attribute values you can predefine fields of the newly created Mbo before it is handed over to the Jython script.

A bit strange is, that if you try to create an Asset Object and do not specify an ASSETNUM you will get an error, that the asset field needs to be specified. If you will set the ASSETNUM field you will get an error, that it is readonly and cannot be set.

The only solution I found so far is to hardly overwrite the readonly check by using the Field Flag “NOACCESSCHECK”:

from psdi.mbo import MboConstants
mbo.setValue("ASSETNUM", "ASS0815", MboConstants.NOACCESSCHECK )
mbo.setValue("DESCRIPTION", "New Test Asset!")

So far for this first tutorial on the new Test script capability. In the next part I will cover the capability to test automation scripts customizing the MIF Interface.

5 comments

  • We are using Maximo CD 7.6 and there is no “Test Script” button or signature in the AUTOSCRIPT application.

    Is this an OOTB funtionality ?

    • Basically this is a OOTB functionality introduced in Maximo 7.6. Not sure if it has been introduced by one of the fix packs. In 7.6.0.7 it is definitely
      included.

  • Recently, I installed Maximo 7.6.0.0 and upgraded it to 7.6.0.8 version with Utility and Spatial Add on.
    1.When I created a basic Object level script to set a description for Asset and Workorder,in both cases I couldn’t see the changes on UI and even logs are not getting printed.
    2.For Jobplan ,Object level script is working.Tried Woactivity and Jobplan attribute launch points,they worked.
    Any reason why it is happening.Moreover,in test functionality process log doesn’t show print statements result.

    Thanks in Advance!!

    • UI changes are always hard to archive with automation scripting since you have no control of ui. For the logging issue have you tried to use the logging command as shown in this articel?

  • Maybe you can help

    When I run this:

    import sys
    print sys.path

    if sys.path.count(‘__pyclasspath__/Lib’) == 1 :
    print ‘path to /Lib already exists’
    else :
    print ‘extend path to /Lib’
    sys.path.append(‘__pyclasspath__/Lib’)

    import socket

    I get this:

    Traceback (most recent call last):
    File “”, line 10, in
    File “__pyclasspath__/Lib/socket.py”, line 11, in
    File “__pyclasspath__/Lib/string.py”, line 122, in
    File “__pyclasspath__/Lib/string.py”, line 115, in __init__
    AttributeError: type object ‘re’ has no attribute ‘escape’

    do you have any input on what might be the cause?

Leave a Reply

Your email address will not be published.