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

ibm_mxmobile_maximo mobile_app_application_suite_report_maintenance_reliability_industry_4_work_order_enterprise_asset_management_inventory_perform_count_log_time_create_meter_reading_shipping_and_recieving_mobility_admin_service_request_issue_parts_material_approve_task_job_plan_software_upgrade
MxMobile Update May 2023 Release
As an IBM Maximo mobile solution provider, A3J Group consistently improves the functionality and features...
Workflow Delegates
Pretend you are going to take a real vacation, two weeks in Spain with no work laptop. You have planned...
ibm_mxmobile_maximo mobile_app_application_suite_report_maintenance_reliability_industry_4_work_order_enterprise_asset_management_inventory_perform_count_log_time_create_meter_reading_shipping_and_recieving_mobility_admin_service_request_issue_parts_material_approve_task_job_plan_software_upgrade
MxMobile Update April 2023 Release
A3J Group is happy to announce the latest MxMobile releases below. The releases will be available on...

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