Maximo Open Forum

 View Only
Expand all | Collapse all

Automatic Start Stop Asset Downtime Automation Script is blocking WOSTATUS record

  • 1.  Automatic Start Stop Asset Downtime Automation Script is blocking WOSTATUS record

    Posted 11-01-2022 20:54

    Do you have any idea why my automation script would prevent the work order's status change from entering a record in the WOSTATUS table? The history flag on cancelled work is also not changing when the change is triggered by the CAN status.

     

    I am trying to automatically change the asset up/down flag and record downtime history for a work order's asset for our EM work types. Everything works, but when the change is triggered by a status change, the work order reflects the new status, but there is no COMP record in the WOSTATUS table.

     Jython script:

     

    from psdi.mbo import MboSet

     

    ownerMbo = mbo.getOwner()

    assetwoset = mbo.getMboSet('RELATEDASSETEM')

    countrelated = assetwoset.count()

     

    if vWORKTYPE=="EM" and vSTATUS in('NEW', 'ASSIGNED', 'INPRG', 'READY2WRK', 'REVIEWED', 'INVESTIGATE') and vISRUNNING==1 and vPARENT is None and vHISTORYFLAG==0:

        downtimereportset = mbo.getMboSet ('DOWNTIMEREPORT')

        downtimereportentry = downtimereportset.add()

        downtimereportentry.setValue("isdowntimereport", "0")

        downtimereportset.execute()

        downtimereportset.save()

    elif vWORKTYPE=="EM" and vSTATUS in('WCMP', 'COMP', 'CLOSE', 'CAN') and vISRUNNING==0 and countrelated==0 and vPARENT is None and vHISTORYFLAG==0:

        downtimereportset = mbo.getMboSet ('DOWNTIMEREPORT')

        downtimereportentry = downtimereportset.add()

        downtimereportentry.setValue("isdowntimereport", "0")

        downtimereportset.execute()

        downtimereportset.save()

     

     


    #Administration
    #Assets
    #Customizations
    #EverythingMaximo
    #Reporting

    ------------------------------
    Sandy Allred
    Northrop Grumman
    ------------------------------


  • 2.  RE: Automatic Start Stop Asset Downtime Automation Script is blocking WOSTATUS record

    Posted 11-02-2022 13:09
    You don't want to call a save on a child set like this. Because the change status will result in a save on WORKORDER, it and any child objects will get saved automatically.

    What's happening is your script calling save is causing the WORKORDER.STATUS field and the ASSETSTATUS to be saved but you're firing before the WOSTATUS Mbo has been created. When the WOSTATUS Mbo gets created, it's associated to the same transaction because it's a child of the WORKORDER. When save is called by the framework a second time it will do nothing because the transaction has already been committed so the WOSTATUS entry isn't committed to the database. By not explicitly calling save, everything should get committed when the change status calls save on the Mbo as part of one transaction. 

    It's rare, but in scenarios where you want something to get committed even if other things later fail, you can open it as an isolated set (utilizing service.getMboSet("OBJECTNAME","whereclause")) where the save will be independent of the record. But in general, you want everything to get saved as part of one transaction so any errors cause the entire thing to rollback.

    ------------------------------
    Steven Shull
    IBM
    ------------------------------