Skip to main content
10-Marble
July 8, 2016
Question

Workflow Complete Code

  • July 8, 2016
  • 1 reply
  • 1699 views

Hey, all!  We're trying to complete a workflow task.  When using it against a Routing-based workflow, no worries.  When used against a Transition-based workflow, the task completes but doesn't move to the next workflow step.  Workflow is still running.  Code:

ReferenceFactory refFactory = new ReferenceFactory();

WTReference workitemref = refFactory.getReference(obidIn);

WorkItem curWorkItem = (WorkItem)workitemref.getObject();

WfAssignedActivity wfAssgAct = (WfAssignedActivity)curWorkItem.getSource().getObject();

ProcessData data = wfAssgAct.getContect();

WfVariable[] list = data.getVariableList();

String associagedOID = (String)list[1].getValueObject();

WTReference wtref = refFactory.getReference(associatedOID);

Object workable = wtref.getObject();

Vector results = new Vector();

results.add("Complete");

wfAssgAct.complete(results);

Thoughts?

1 reply

10-Marble
July 9, 2016

Figured it out.

   curWorkItem.setComplete("Fast_Track");
   PersistenceHelper.manager.save(curWorkItem);
   wfAssgAct.changeState(WfTransition.COMPLETE);
10-Marble
August 8, 2016

To follow up, the .setComplete("string") code sets an attribute for who approved it.  So the code should call the current principal and put their username into that field.