Automation script to create a Change from other systems

About this task

An automation script is configured to create a new Change record in Maximo IT from an external system such as a third-party application, integration, or a REST API call. The script listens for a request, reads parameters, and then creates a new Change record in Maximo IT using those values.

Follow the steps below to create the automation script:

Procedure

  1. Open the Automation Scripts application.
  2. On the navigation panel, click Create and select Script.
  3. On the Create Script pop-up, enter the details in the fields as follows:
    • Object: Search for the WOCHANGE object and select it.
    • Check the checkbox for Active? and click Next.
    • Specify Script name as CREATECHANGE.
    • Script: Specify as Jython
    • Script Language: Search and select jython
    • Log level: Search and select ERROR
    • Click Next.
    • You can import the below script or paste it on the below script box, and click Create.
    Note: The below script is a sample and for reference only, update the script as per your custom field ID's and other changes as necessary.
    #Script Name: CREATECHANGE
    #DESCRIPTION: Create a Change from other systems.
    #Script Language: jython
    #Log Level: ERROR
    
    from psdi.mbo import Mbo 
    from psdi.mbo import MboSet 
    from psdi.mbo import MboConstants
    from psdi.mbo import MboRemote 
    from psdi.server import MXServer
     
      
    server = MXServer.getMXServer() 
    #user = scriptHome.getUserInfo() 
    userInfo = MXServer.getMXServer().getUserInfo("MAXADMIN") 
    chagneSet = server.getMboSet("WOCHANGE",  userInfo)
    changeMbo = chagneSet.add() 
    desc = request.getQueryParam("desc") 
    reason = request.getQueryParam("reason")
    changeMbo.setValue("DESCRIPTION", desc) 
    changeMbo.setValue("REASONFORCHANGE",reason)
    changeNum=changeMbo.getString("WONUM")
    chagneSet.save() 
    responseBody = "Record Created -"+ changeNum
  4. Save your changes.