Maximo Open Forum

 View Only
  • 1.  Does anyone know how to stop a workflow through automation script?

    Posted 06-30-2021 08:19
    Does anyone know how to stop a workflow through automation script?

    Thx
    #Customizations
    #EverythingMaximo

    ------------------------------
    André Cordeiro
    AQUASIS
    ------------------------------


  • 2.  RE: Does anyone know how to stop a workflow through automation script?

    Posted 06-30-2021 08:29
    I haven't had to do this personally, so I'd look deeper into this and make sure it works as you intend. But I believe you just have to get the workflow instance MBO record that you want to stop and then invoke the stopWorkflow(memo) method. Something like:

    wfInstanceSet=mbo.getMboSet("$EMXWFINSTANCE","WFINSTANCE","processname='MYWORKFLOW' and ownertable='WORKORDER' and ownerid=:workorderid and active=1")
    wfInstanceMbo=wfInstanceSet.moveFirst()
    if wfInstanceMbo:
        wfInstanceMbo.stopWorkflow("Stopped via script")​


    ------------------------------
    Steven Shull
    Projetech Inc.
    ------------------------------



  • 3.  RE: Does anyone know how to stop a workflow through automation script?

    Posted 06-30-2021 13:59
    Hi Steven,

    You are the man ;)

    It worked just fine.

    Thanks a lot

    ------------------------------
    André Cordeiro
    AQUASIS
    ------------------------------



  • 4.  RE: Does anyone know how to stop a workflow through automation script?

    Posted 02-16-2022 21:10
    Hi Steven,
    Is there a way you can stop the workflow followed by changing the status as a Single Transaction ? I am trying to do this via an Interface,  it expects the Mboset associated with the wfInstance needs to be saved first before you can change the status, otherwise it gives the PVStatus error on status change
    The reason i need to do it as 1 transaction, if for some reason the status changes fails, it would be a partial commit, as the mbo is out of the workflow.
    I tried adding the WFInstanceMboSet to the MxTransaction, still did not work.

    Thanks,
    Pratap

    ------------------------------
    Pratap Seetharaman
    DTE Energy
    ------------------------------



  • 5.  RE: Does anyone know how to stop a workflow through automation script?

    Posted 02-17-2022 11:51
    Edited by Steven Shull 02-18-2022 09:17

    That wouldn't work without changing your database settings to a dangerous (and not recommended/supported) configuration. Each database platform calls it something different (SQL Server calls it Read Committed Snapshot for example) but when you write a query, you're typically getting what has been committed to the database. If both things are part of the same transaction, the data hasn't been committed yet and thus when the check is made, it will see that it's in a workflow and that it is set to not allow status changes.

    I haven't tried this, but what about applying the OKSTATUS action to your MBO directly prior to making the status change? Something like:

    actionSet = mbo.getMboSet("$EMXOKACTION","ACTION","action='OKSTATUS'")
    actionMbo=actionSet.moveFirst()
    if actionMbo:
        actionMbo.executeAction(mbo)



    ------------------------------
    Steven Shull
    IBM
    ------------------------------