workflowmaximo

Is it possible to continue existing maximo workflow instance from automation script


In our PR program in maximo, we have a workflow that will route the PR to other team for approval. but the approval process is from email that we create outside of maximo. I would like to know is it possible to continue the workflow instance from automation script?

Right now I create the automation script like this

assignmentSet = mx.getMboSet("WFASSIGNMENT",ui);
assignmentSet.setWhere(" WFASSIGNMENTID = " + str(mbo.getLong("WFASSIGNMENTID")));
assignment = assignmentSet.moveFirst();

if(assignment.getString("ASSIGNSTATUS")=="ACTIVE" and NEXTNODE > 0):
    wfstackSet = mx.getMboSet("WFCALLSTACK",ui);
    wfstackSet.setWhere(" WFID = " + str(mbo.getLong("WFINSTANCEID")));
    wfstack = wfstackSet.moveFirst();
    if (wfstack.getInt("NODEID")==mbo.getInt("NODEID")):
        wfstack.setValue("NODEID",NEXTNODE,2L);
    wfstackSet.save();
    wfstackSet.close();
    
    assignment.setValue("ASSIGNSTATUS","COMPLETE", 2L);

assignmentSet.save();
assignmentSet.close();

This automation script is only change the workflow maps, but not creating another assignment. Can someone tell me if there's a missing mbo that i need to update in order the workflow to continue to next node? Thank you.


Solution

  • Thank to @Maximo.Wiki. I found a solution from your link we can continue the workflow using automation script like this

    assignmentSet = mx.getMboSet("WFASSIGNMENT",ui);
    assignmentSet.setWhere(" WFASSIGNMENTID = " + str(mbo.getLong("WFASSIGNMENTID")));
    assignment = assignmentSet.moveFirst();
    MXServer.getMXServer().lookup("WORKFLOW").completeAssignment(assignment, "APPROVE  PR", 1);
    

    or rejecting it like this

    MXServer.getMXServer().lookup("WORKFLOW").completeAssignment(assignment, "REJECT PR ", 0);
    

    but with this, it will failed if you put ManualInput node in the workflow, to solve this I add another field in the object