Maximo Open Forum

 View Only

 Inspection Form Association to Work Orders

  • End User
  • Everything Maximo
  • Integrations
  • Maximo Application Suite
  • Safety
  • Work Management
David Pattengale's profile image
David Pattengale posted 11-12-2024 07:44

Greetings,

I have created an inspection form based Task Hazard Analysis that I would like to associate with every new work order created. These are every type of WO, so many have no Job Plan. What is the best way to accomplish this? I am not the best at coding, so I would appreciate any help I could get.

Jason VenHuizen's profile image
Jason VenHuizen

Same answer as on the TechXchange, but here for others benefit as well.

# The inspection form number you want to apply.
inspection_form = "1001" # In the MAXDEMO database, this is the Portable Ladder Inspection

def main():
    # Check that this is being invoked from an Object save and that the object is a WORKORDER and not a task.
    if ("mbo" in globals() and mbo.isBasedOn("WORKORDER") and not mbo.getBoolean("ISTASK") and mbo.toBeAdded()):
        # This is here for demonstration purposes, to show how you might filter this to specific work types.
        if(mbo.getString("WORKTYPE") == "CM"):
            mbo.setValue("INSPFORMNUM", inspection_form)

# Call the main function, ensuring there is a single entry point to the script.
main()

scriptConfig="""{
    "autoscript": "WORKORDER.APPLY.THA",
    "description": "Apply task hazard analysis to every work order created.",
    "version": "1.0.0",
    "active": true,
    "logLevel": "ERROR",
    "scriptLaunchPoints": [
        {
            "launchPointName": "WORKORDER.APPLY.THA",
            "launchPointType": "OBJECT",
            "active": true,
            "description": "Apply task hazard analysis to every work order created.",
            "objectName": "WORKORDER",
            "save": true,
            "add": true,
            "update": false,
            "delete": false,
            "beforeSave": true
        }   
    ] 
}"""

David Pattengale's profile image
David Pattengale

Thank you Jason, this is perfect!