Workflow which changes state manually

40 views
Skip to first unread message

Aboobacker N K

unread,
Oct 4, 2021, 6:04:50 AM10/4/21
to nflow-users
Hi Team , 

I am trying to create a workflow which changes its state only when an external change happens. Basically the workflow am planning to have only these below states. 

submit(start, "Submitted"), //
review(manual, "Under review"), //
approve(end, "Approved"), //
needMoreInfo(manual, "Require more information"), //
reject(end, "Rejected");

I want to manually go from one state to another. But am getting bean exception if dont create next action method for state submit , so am forced to right atleast one state that moves automatically to an another state , Is there any way to achieve the usecase am trying for ?

And is there any way to restrict traveral to states which are not allowed to make transition ?

that is like submit -> needMoreInfo

Thanks in advance !

Thanks & Regards
Aboobacker N K

nflow-users

unread,
Nov 1, 2021, 3:24:54 PM11/1/21
to nflow-users
Hi,

Sorry for late answer.

At the moment, nFlow requires at least one start state per workflow, and start state must have a method, and the initial state of the workflow instance must be a start state. So you are forced to have at least one method that automatically moves to another state. However, it shouldn't be a big deal to change this, would you like to open an issue in nFlow github project or even make a PR?

Currently illegal state transitions are not restricted by nFlow engine. "nflow.illegal.state.change.action" configuration option controls what happens when illegal state transition happens (see https://github.com/NitorCreations/nflow/wiki/Configuration for details), but for now it does not have an option to deny the transition. This could probably also be supported in future, you could open an issue of make a PR for this, too.

br, Edvard

Steve O

unread,
Nov 1, 2021, 3:55:55 PM11/1/21
to nflow-users

Hi, I have searched the internet over for examples on how to do real things with manual steps.  It is not clear to me since there don't seem to be any available examples of manual states.  I want to launch a workflow, have it do some preliminary processing on some state data with which it was initialized.  Then go to a manual state where it waits for external input say from a REST method implemented by a Spring boot controller.  IN that rest method I want to get the workflow which should be sleeping at this point, append some information to the state variable and then do whatever processing should be done post that change.  Manual steps are quite opaque at the present time.

Edvard Fonsell

unread,
Nov 2, 2021, 6:41:35 AM11/2/21
to nflow-users
Hi,

In nFlow, "manual steps" are something that is not controlled by nFlow workflows. It may be some human interaction or some other system doing something. As you said, the manual state is just waiting for some external actor to do something, and when it's done, the external actor should update the workflow instance to the next state. Before that, the external actor may put some information to state variables or to some other data storage, which may then be used by the workflow instance in the next state.

I'm not sure what you were asking or if you were asking anything, but I hope this helps :)

br, Edvard

Steve O

unread,
Nov 2, 2021, 9:41:20 PM11/2/21
to nflow-users

Exactly how does the external actor update the workflow instance to the next state?  WorkflowInstance.state is final.  So WorkflowInstanceAction.Builder(workflowInstance) can't be used to update the state.

nflow-users

unread,
Nov 3, 2021, 2:58:01 AM11/3/21
to nflow-users
Hi,

Use WorkflowInstanceService.updateWorkflowInstance() and WorkflowInstance.Builder to create a new (modified) workflow instance, see ResourceBase.updateWorkflowInstance() for an example how nFlow Rest API does it.

br, Edvard
Reply all
Reply to author
Forward
0 new messages