Skip to main contentCarbon Design System

Invoking workflow from inbound MIF

The current UI framework allows you to automatically invoke a workflow when you save the application MBO. The following sample python example invokes a workflow that will create an assignment when a new workorder is created using Maxmio Integration Framework (MIF) inbound:

To do this, you will write an Object Structure script that will invoke the workflow. You will use the new Integration Scripts action from the Automation Scripting application. Select the options:

Object Structure -> MXWODETAIL (Object Structure name) ->Inbound Processing.

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

Thectx var is the same as the global implicit var service but with added functionality for Object Structure processing.

A simple way to test this would be 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”
}

Once you POST this json, it will invoke the script and will create an assignment for the logged in user. You can verify that from the start center assignments portlet.

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