How to create follow-up Work Order with script

Maximo provides a useful action in many applications to create a follow-up work order or a linked service request from many applications.

The same result can easily be automated using the WO.createWorkorder() or the Ticket.createWorkorder() API methods.

The standard WO2WO or TICKET2WO crossover domains can also be used to copy some attributes from the source object to the new one.

However, sometimes you need more control to automate the initialization of the new record. In this cases you may use more powerful versions of the createWorkorder() method.

To create a work order from another work order you can use the WO.createWorkorder(woSet, jp, save) method that returns the created MBO. Passing False to the third parameter will tell Maximo not to save the work order so you can make the required actions before calling the save() method on the MboSet.

The following Python script explains how to use this method to create a follow-up work order and set the priority and work type.

woSet = mbo.getMboServer().getMboSet("WORKORDER", mbo.getUserInfo())
wo = mbo.createWorkorder(woSet, None, False)
wo.setValue("WORKTYPE", 'CM', mbo.NOACCESSCHECK)
wo.setValue("PRIORITY", 4, mbo.NOACCESSCHECK)
woSet.save()

A similar method is available on the Ticket class but returns an list of created MBOs. This is because a ticket can generate many work orders based on the value of the CREATEWOMULTI attribute. Here is a similar script to be used on tickets (SR).

woSet = mbo.getMboServer().getMboSet("WORKORDER", mbo.getUserInfo())
woList = mbo.createWorkorder(woSet, False)
wo = woList[1]
wo.setValue("WORKTYPE", 'CM', mbo.NOACCESSCHECK)
wo.setValue("PRIORITY", 4, mbo.NOACCESSCHECK)
woSet.save()

How to create follow-up Work Order with script

3 thoughts on “How to create follow-up Work Order with script

  1. Nice script , but how system knows when to create a follow -up work order

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top