Skip to content

MBOs in Automation Scripts: Adding New Objects to the Collection

In our previous posts in this series, we talked about how an MboSet is a collection of Mbo objects. This is analogous to a spreadsheet of data representing an MboSet, and a single row within that spreadsheet representing an Mbo. This article will discuss how to update single attributes on an Mbo, or in our spreadsheet analogy, update data within a single cell within a row. If there is a need to add a new object to a collection, the add() method may be on an MboSet, as in the following example:
newWo = woSet.add()
This returns a reference to the newly added object and sets the current index in the collection to point to it. The location of the new object within the collection is not guaranteed, so no assumptions should be made as to where it has been placed relative to the previous current index. You can use the getString() method to fetch default or autokey values for particular attributes. One of the best examples of an autokey value is the “wonum” attribute, which must be unique as the principal identifier of a work order. These values are set automatically by Maximo as part of the add() method. Once a new object has been created, the attributes of the object can be altered by using the setValue() method. This method call can be performed directly on the newly added object:
newWo.setValue("assetnum", "11430")
As mentioned previously, changing an attribute value may result in other attribute values being updated. Once all values have been set, the save() method should then be called:
The save() method may throw an exception, as was discussed in the section on modifying objects. The most common exception thrown by the saving of a newly added object results from a required attribute not being set. The exception returned in this case is of type MXApplicationException with an error group and key of “system” and “null”, respectively. Our next article will focus on exception handling with Mbos and MboSets.

Share This

Related Posts

How to Enable Print Functionality in IBM Maximo
How to enable the print button in Maximo.   By default, Maximo only allows the MAXADMIN group to have...
WBENC Anoounement thumbnail
Customizing Ad Hoc Reports
We all want to make our Maximo reports as informative and readable as possible, but sometimes the available...

3 Responses


  1. Hi Alex.. can you please help me in writing a script on attribute launch point for the below requirement?
    In asset templates application, when user adds a master pm to it, an attribute(x) in asset template application and an attribute(y) in jobplan that’s attached to master pm that user added in asset templates application has to match. If it doesn’t match, error should be displayed.
    ATTRIBUTE in PLUSCTEMPLATE and ATTRIBUTE in JOBPLAN should be compared. Please help!

  2. Hi Alex. I am trying to copy the values from existing table in maximo to new one one that is created by me. So when the status changes in work order the values of child object in workorder app will be copied to new table. The structure of tables are the sames i mean the same attributes. First i try to copy just one value but it doesnt copy. And there is no error showed up.

    from psdi.server import MXServer
    from psdi.mbo import Mbo
    from psdi.mbo import MboConstants

    from psdi.util.logging import MXLoggerFactory
    logger = MXLoggerFactory.getLogger(“maximo.script”)

    sourceItemSet= mbo.getMboSet(“SHOWPLANITEM”)

    targetItemSet= mbo.getMboSet(“PLANNEDZ0WPITEM”)

    status = mbo.getString(“STATUS”)

    if status in (“AVVIATO”):
    for i in range (0, sourceItemSet.count()):
    if targetItemSet is not None:
    wonum =sourceItemSet.getMbo(i).getString(“WONUM”)“COMPY VALUES” + ” – ” + wonum )
    newMbo.setValue(“WONUM”,wonum,MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION)

  3. Aynura Mahmudova – did you save your new set?

Add a Comment