Integration with workflow

The user interface framework enables you to automatically start a workflow when you save the application Maximo® business object (MBO).

The following Python example starts a workflow that creates an assignment when a new work order is created by using Maximo Integration Framework inbound. To do this, write an object structure script that starts the workflow. From the Automation Scripts application, select Create > Script for Integration. In the Create Script for Integration dialog, select Object Structure. Enter the object structure name in the Object Structure field, for example, MXWODETAIL. Select Inbound Processing.
from psdi.server import MXServer

def afterProcess(ctx):
  mbo = ctx.getPrimaryMbo()
  if mbo.isNew():
    MXServer.getMXServer().lookup("WORKFLOW").initiateWorkflow("WOSTATUS",mbo)

The ctx variable is the same as the global implicit variable service but with added functions for object structure processing.

A simple way to test this is to use the following REST JSON API.
POST http://host:port/maximo/oslc/os/mxwodetail?lean=1
{
“wonum”:”MYLABWO11”,
“siteid”:”BEDFORD”,
“description”:”Invoke workflow test”
}

After you POST this JSON, it invokes the script and creates an assignment for the logged-in user. You can verify that assignment from the Assignments portlet.

You can enhance the script to make sure that this workflow initiation is done only for transactions that have the status as WAPPR. You can use the ctx.getPrimaryMbo() to check that.