NitorCreations/nflow

Manually move a workflow from wait/manual to another state.

orderrrr opened this issue · 2 comments

Hi there,

I have a use case for nflow where there are multiple steps that need external inputs to progress further.
As an example the user will approve the workflow which will move the state from pending to whatever next step there is.

Is there a way to do this?

currently I have a workflow in the following state:
public static final State PENDING = new State("pending", wait, "Wait for approval");

I've tried to move it to the next state with the following:

		workflowInstances.updateWorkflowInstance(
				workflowInstance,
				new WorkflowInstanceAction.Builder(workflowInstance)
						.setState(CustomWorkflow.PROGRESS_STATE.name())
						.setType(WorkflowInstanceAction.WorkflowActionType.externalChange)
						.setRetryNo(1)
						.setExecutionEnd(now())
						.build());

However all this seems to do is move it to do is create an action but nothing else.

What is the correct way to do this?

I could have in my workflow action step look for an external change in a state var.
But this step is time sensitive so the quicker the better.

You should set the state to the workflowInstance, not to the action. Something like this:

  workflowInstances.updateWorkflowInstance(
    new WorkflowInstace.Builder(workflowInstance)
      .setState(CustomWorkflow.PROGRESS_STATE.name())
      .build(),
    new WorkflowInstanceAction.Builder(workflowInstance)
      .setType(WorkflowInstanceAction.WorkflowActionType.externalChange)
      .setRetryNo(1)
      .setExecutionEnd(now())
      .build());

That was it, thank you!