Initiate a workflow from an Automation Script.
from psdi.server import MXServer
mxs = MXServer.getMXServer()
wfstart = mxs.lookup('WORKFLOW')
wfstart.initiateWorkflow('CSPREIMB',mbo)
-------------------------
Or define a function in your script and call it whenever needed as below:
Function Defination:
def startwf(a):
actionSet = MXServer.getMXServer().getMboSet("action", a.getUserInfo());
sqf = SqlFormat("action = :1")
sqf.setObject(1, "action", "action", "STWFEUNRI")
actionSet.setWhere(sqf.format())
actionSet.reset()
actionSet.getMbo(0).executeAction(a)
Function Call:
startwf(MboVariable)
2. Stop an active workflow from the Automation Script.
from psdi.server import MXServer
mxs = MXServer.getMXServer().lookup('WORKFLOW')
wfstop = mxs.getActiveInstances(mbo)
wfstart.getMbo(0).stopWorkflow('Stopped')
or
wfInstanceSet=mbo.getMboSet("$wfInstanceSet","WFINSTANCE","processname='IBMMAINWF' and ownertable='WORKORDER' and ownerid=:workorderid and active=1")
wfInstanceMbo=wfInstanceSet.moveFirst()
if wfInstanceMbo:
wfInstanceMbo.stopWorkflow("Stopped because Type becomes DLP")
No comments:
Post a Comment