Kamis, 28 Agustus 2014

How to launch Workflow

Today I want to show you all the possible ways (as far as I know) of starting a workflow in Maximo.


Interactive initiate

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.


Escalation

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
  • Condition:
  • Schedule: 5m,*,*,*,*,*,*,*,*,* (every 5 minutes)
  • Escalation Points
    • Escalation Point: 1
    • Repeat: false
    • Leave other fields empty
  • Actions
    • 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.


Java

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)
stopWorkflow(String memo)

This article has a nice example of it.

Another option is to use psdi.workflow.WorkFlowService class. The initiateWorkflow(String processName, MboRemote 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();
wfsr.initiateWorkFlow("[MYWF]", mbo);


Script

Similarly to Java it is possible to use the above methods to start a workflow using TPAE scripting.

from psdi.server import MXServer
MXServer.getMXServer().lookup("WORKFLOW").initiateWorkflow("[MYWF]",mbo);


Integration Framework

In this IBM TechNote is described a new feature introduced in TPAE 7.1.1.6 to start a workflow with an HTTP call to MIF.
There is also another TechNote about this.

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.


REST

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.


Source:http://maximodev.blogspot.com/2014/01/how-to-launch-workflow.html

Tidak ada komentar:

Posting Komentar