Today I want to show you all the possible ways (as far as I know) of starting a workflow in Maximo.
This is the most basic way of automatically start a workflow when an object is created through the user interface. This technique will not work for objects created by MIF, workflows or escalations.
To enable workflow auto-initiate open your workflow in Workflow Designer and select the Interactive Initiate checkbox.
Another way of activating a workflow is through an escalation.
Go to the Actions application and create a new action like this:
- Action: STARTWF
- Description: Start TESTWF workflow
- Object: WORKORDER
- Type: APPACTION
- Value: WFINITIATE
- Parameter/Attribute: TESTWF
- Accessible from: ESCALATION
Now setup an escalation to trigger the STARTWF action:
- Escalation: STARTWF
- Applies to: WORKORDER
- Schedule: 5m,*,*,*,*,*,*,*,*,* (every 5 minutes)
- Escalation Points
- Escalation Point: 1
- Repeat: false
- Leave other fields empty
- Action: STARTWF
Don’t forget to activate the escalation.
Application Toolbar Button, Action Menu or pushbutton
If you wand to let the user manually trigger a workflow from an application you have several options.
Typically this is done creating a new button on the toolbar but you can also create a new action in the menu or add a pushbutton to the application itself.
Open your application in the Application Designer.
Add the control to which you want to attach the workfow start
Set the control properties as follows:
- mxevent: ROUTEWF
- value: [MYWF]
Obviously you have to replace [MYWF] with the name of your workflow.
There are two useful methods that can be used to start and stop a workflow on an MBO. Both are located into psdi.workflow.WFInstance class.
initiateWorkflow(String memo, WFProcess wfProcess)
This article has a nice example of it.
Another option is to use psdi.workflow.WorkFlowService.initiateWorkflow(processName, target) allows to easily start a workflow on a specific MBO. The Java code should be something like this:
MXServer mx = MXServer.getMXServer();
WorkFlowServiceRemote wfsr = (WorkFlowServiceRemote)mx.lookup("WORKFLOW");
MBORemote mbo = (MBORemote)getMbo();
Similarly to Java it is possible to use the above methods to start a workflow using TPAE scripting.
from psdi.server import MXServer
A more general approach would be to add a custom YORN field named STARTWF and set it to 1 through MIF. An escalation can then start the workflow for all the objects that has STARTWF=1 and then reset the STARTWF flag to 0.
A REST call can also be used. An example URI is the following:
POST /maxrest/rest/mbo/po/6789?wfname=MYWF HTTP/1.1 x-http-method-override: “initiateWorkflow”
Replace PO with your MBO name, 6789 with the ID of the new record and MYWF with your workflow name.