Search code examples
maximo

IBM Maximo: Use automation script to update an attribute on a related object


I have an automation script with an Object Launch Point on the ASSET object. ASSET has a relationship called VALVEOP. I would like to update the "assetnum" attribute on the VALVEOP object as part of this automation script. What is the best way to go about doing this?


Solution

  • Here’s a basic example of how you might write an automation script in IBM Maximo to update the “assetnum” attribute on the VALVEOP object. This script assumes that you have an Object Launch Point on the ASSET object.

    from psdi.mbo import MboConstants
    
    # Get the current ASSET Mbo
    assetMbo = mbo
    
    # Get the related VALVEOP MboSet
    valveopMboSet = assetMbo.getMboSet("VALVEOP")
    
    # Loop through each VALVEOP Mbo in the MboSet
    valveopMbo = valveopMboSet.moveFirst()
    while valveopMbo:
        # Update the "assetnum" attribute
        valveopMbo.setValue("assetnum", assetMbo.getString("ASSETNUM" , MboConstants.NOACCESSCHECK)
    
        # Move to the next VALVEOP Mbo
        valveopMbo = valveopMboSet.moveNext()
    

    Note: You don't have to call the save mboset explicitly if you are using object launch point on save event. However if the record is not saved, you may use the below statement.

    # Save the changes
    assetMbo.getThisMboSet().save()