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.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();
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.

How to launch Workflow

14 thoughts on “How to launch Workflow

  1. Hi Bruno, how're you?

    I'm trying to apply a SLA automatically when the user save a SR, but, some times, the SLA has already been applied and because changes in SR must be reapplied.

    So, I create a WF to apply my SLA and in the first moment, I tried make this by bean class thus:

    public int SAVE()
    throws MXException, RemoteException
    {
    int result = super.SAVE();
    try
    {
    MXServer mxs = MXServer.getMXServer();
    WorkFlowServiceRemote wsrmt = (WorkFlowServiceRemote)mxs.lookup("WORKFLOW");

    SRRemote mbo = (SRRemote)getMbo();
    wsrmt.initiateWorkflow("WFSLASR", mbo);
    fireStructureChangedEvent();
    refreshTable();
    this.sessionContext.queueRefreshEvent();
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    return result;
    }

    But here, I can't access the method getMboValue().getPreviusValue() to verify if an attribute of my SR was changed. So I decided to make this in a Mbo Class. Thus, I'm trying to do that way:

    protected void save() throws MXException, RemoteException {

    boolean startWF = applyAutomaticSLA(); //here I test if is needed to reapply the SLA

    super.save();

    if(startWF){
    try {
    //Start the WF to apply the SLA
    MXServer mxs = MXServer.getMXServer();
    WorkFlowServiceRemote wsrmt = (WorkFlowServiceRemote) mxs.lookup("WORKFLOW");

    wsrmt.initiateWorkflow("WFSLASR", (SRRemote) this);

    //Here, I want to show to end user a status message saying to wait because the system is recalculating the SLA
    this.getThisMboSet().addWarning(new MXApplicationException("ticket", "recalcSLA"));

    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }

    What my problem is… When I change the field to reapply my SLA and I click in the SAVE button, the Maximo stay in loop, saving the SR repeatedly.

    How can I do this?

    Thanks for your help.

  2. Hi Bruno.

    Debugging my code, a discovery that problem is when I try to initiate the workflow. When I do this: wsrmt.initiateWorkflow("WFSLASR", (SRRemote) this); the record don't save and return to begin.

    Can you help please?

    Thank you.

  3. Hi Bruno
    Do you have an idea how we can call maximo internal action i.e. REVPO ( revise PO ) from workflow?
    I want to make a workflow to process PO Revision ?

  4. Hi Bruno,

    I am trying to user your example on to initiate workflow through the REST API and i can't get it to work. I followed your example and changed the MBO to WORKORDER and added my wonum and replaced MYWF with my workflow name and the status never changed. Did i do something wrong?

    Any help would be appreciated.

  5. Hi Bruno,

    As you said in first point , Interactive Initiate is working fine for TSRM created TTs(Created in TSRM portal) but not working for auto TTs from External System integrated with TSRM(IBM Netcool) and for Child Tickets. How can auto assign workflow to Auto TTs and child TTs..

    Pls Suggest…

    Thanks

  6. In one application, I removed the SAVE button and created a workflow go button that was assigned the SAVE icon. So, every time the user saved, it performed the intrinsic save and ran the small workflow (really more of a script in this case). The drawback of this approach is if the user saves through another method, such as clicking back to list view and getting the save prompt, of course it won't run. But in the case where I used it, it was not critical to run the workflow every time it saved.

    The funny thing to me was that when I made the change, no one ever commented that the save button had moved to a different place.

  7. Hi Bruno,

    I wonder if it possible to initiate a workflow using a Runtime event (like in Siebel if you are familiar).
    Example of runtime event: Run an Action if field Status of Object 'SR' is set
    Example of runtime event (2): Run an Action if a record in object 'SR' is Saved

    Thanks,

    Fotis

  8. POST /maxrest/rest/mbo/po/6789?wfname=MYWF HTTP/1.1 x-http-method-override: "initiateWorkflow"
    we are using this type of call to initiate wf but we do want to stop the wf with a rest call is it possible if so how do i leverage it

  9. Hi Bruno, a question: When I want to start a workflow through script how can I identified what version of workflow I want to run?. For example when there are different versions of a workflow.

    Thanks and Regards

  10. Hi Bruno,

    Are we able to initiate the workflow for a specific user with the Automation Script? This would help in a situation where the user’s details help in the workflow limits and required checks.

Leave a Reply to Bruno Portaluri Cancel reply

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

Scroll to top