Deleting Mbo’s

So far we know how to insert, update and view our Mbo records, so the next step is to delete a record.

You delete Mbo’s by calling the delete() method. This method removes the current Mbo from an MboSet. Basically the Mbo is not delete when you call the delete method it is more over marked for deletion. The real delete operation is executed when the transaction is commit to the database. In general this is the save operation on the MboSet.

Here comes an example which deletes a specifc Workorder from the Workorder MboSet:

    # Example: Delete a specific Mbo
    woset = session.getMboSet('WORKORDER')
    woset.setWhere("WONUM = '2009'")
    woset.reset()
    wo = woset.moveFirst()
    
    if wo is not None:   
        # Mark Mbo for deletion
        wo.delete()

        # Real delete is done at this point
        woset.save()

3 comments

  • Hi,
    I am new to Maximo and Jython and I have one doubt that if a user deletes a row on UI, how will we come to know that out of suppose 5 rows (MBOs) which record I have to delete ?

    Is there any flag or something by which we can know in our script that this is the record to be deleted ?

  • if (woMbo.toBeDeleted()):
    …write your code…

  • Exzellent Tip Sourabh! Thanks!