Skip to content

MBOs in Automation Scripts: Update Attributes of an Mbo

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. To modify an object in the collection, the object must first be found. Most of the time, the launch points in automation scripts will supply an implicit variable called mbo that refers to the current record. Alternatively, you can get a handle to an Mbo from an MboSet as described in previous articles of this series – remember the setWhere() and moveFirst() methods. Once you have an Mbo, changes are made using the setValue() method. As is the case with other methods, setValue() is a member of both the Mbo and MboSet classes. Our first example changes the description of the current Mbo (a work order) by calling the mbo variable’s version of the setValue() method.
mbo.setValue("DESCRIPTION", "Changed the description")
In the setValue() method, passing the second argument as a string works for all attributes, regardless of their underlying data types. For example, if an attribute is a numeric type, passing the string “1” is allowed. There are also setValue() method calls that take the long, int, Date, boolean, float, or double data types as the second argument. This call will throw an exception if the underlying data type does not match the type of the value passed in the call. For example the following code does not work.
mbo.setValue("description", 1.0)
A call to set the value of a particular attribute may result in the values of other attributes changing. For example, setting the “assetnum” attribute of a work order may result in the “location” attribute being updated as well. To check the new value, getString() could be used on the “location” attribute. Once all values have been modified, the save() method can then be called.
This saves and commits all changes to the database. In most cases, an explicit call to save() is not necessary. In cases where the automation script fires before the save event, the save event will trigger automatically after the execution of the script. If there is an error during the save, an exception is thrown and the changes are not saved. In that case, the collection is left in exactly the same state as prior to the save() call. This allows appropriate action to be taken and the save() call to be resubmitted. There is a third argument that can be passed to the setValue() method, which is the Access Modifier. This should only be used when you are certain of the implications of using it. In essence, standard application logic can be bypassed by using access modifiers, which is why they should be used only when necessary. Standard access modifiers are:
  1. NOACCESSCHECK: Suppresses the “Field is Read Only” message and performs the update regardless of whether the field is editable or not.
  2. NOVALIDATION: Update the field without validating the data being entered.
  3. NOACTION: Do not perform related system actions when updating. For example, do not update the location on a work order when updating the asset.
These access modifiers can be used on an update by themselves or combined together. For example, to update a field even though Maximo has the field marked as read only:
mbo.setValue("DESCRIPTION", "Update a read only field", mbo.NOACCESSCHECK)
To update a field and not perform the validation and action events:
mbo.setValue("DESCRIPTION", "Update a field without validation or action", mbo.NOVALIDATION|mbo.NOACTION)
Putting all three together:
mbo.setValue("DESCRIPTION", "Please be careful doing this", mbo.NOACCESSCHECK|mbo.NOVALIDATION|mbo.NOACTION)
A list of attributes whose values may be modified and the objects to which they belong can be found in the MAXATTRIBUTE table in the MAXIMO database. The OBJECTNAME column of this table corresponds to the object name. The ATTRIBUTENAME column corresponds to the attribute name. Our next article will focus on how to add new Mbo records into an MboSet.

Share This

Related Posts

Preventing fields from Editing Once Record is in Workflow
Preventing fields from Editing Once Record is in Workflow I like this problem because it involves a few...
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

5 Responses


  1. This was very informative and awesome. Thank you, Alex.

    Does capitalization matter with the keys for Mbo? Would mbo.setValue(“ACCESS_KEY”, “5^*^%$TRUE”); change the same cell as mbo.setValue(“AccessKey, “5^*^%$TRUE”);

    Why does this happen?
    A call to set the value of a particular attribute may result in the values of other attributes changing. For example, setting the “assetnum” attribute of a work order may result in the “location” attribute being updated as well. To check the new value, getString() could be used on the “location” attribute.

    In most cases, an explicit call to save() is not necessary.
    What makes it a case where it is necessary?

    • No problem, thanks for the questions!

      1. Capitalization does not matter. Maximo will locate the correct attribute to update regardless of the case you use to identify it.
      2. Business rules in Maximo may apply to certain fields. The location of a work order is updated automatically when an asset is updated because the asset resides in a certain location. If the location is empty and an asset is chosen, you would want the location to default to that of the asset you selected. This is a simple case, but it extends throughout the Maximo application.
      3. The call to save() is not necessary if you update an MboSet that is related to the current Mbo. This is because the save() will automatically fire on the current record, and any related MboSet’s will also be saved. If you get an independent MboSet from the MXServer (see examples from the first article in this series) you will need to explicitly save.

      Hope this helps!

  2. Hi Alex.
    I wrote this script to copy the value from existing table in maximo to my new table. The tables are the same i mean same attributes. So when the status changes it should pass from old table to the new one.
    First i try to add just work order number but it doesnt copy the values and it doesnt give any error.

    #Add records in Z0PLANNEDCOST table when the new work order added to the workflow.

    #Attribute Launch Point: STATUS

    from psdi.server import MXServer
    from psdi.mbo import Mbo
    from psdi.mbo import MboConstants
    from psdi.mbo import MboRemote
    from psdi.mbo import MboSetRemote
    import sys

    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. Hi I’m writing a script automation with object launch point and it’s raises error message “indefined mbo variable” on this line mbo.SetFieldFlag(“quantity”,MboConstants.READONLY,false). I don’t understand this error because it’s supposed that mbo is an explicit variable.

    Thanks and regards


    • If you’re using an Object launch point, then you should have mbo as an implicit variable to the script. To make a field read-only, you’ll probably want to use the initialize value event that’s part of the Object launch point.

      As for the code, since the Mbo class implements MboConstants you can write your script like this. Please note this is python syntax:
      mbo.setFieldFlag("quantity", mbo.READONLY, False)

      Hope this helps,

Add a Comment