Skip to main content

Introducing Formengine - The New Formbuilder, try for FREE formengine.io.

Setting process state

In this article we will describe the mechanism that is provided by Workflow Engine to change or set the State or Activity inside a process.

ProcessInstance

There are four different methods that can be used in ProcessInstance class. These methods can be used inside the CodeAction code, and they can be called in any Activity. Moreover, these methods are useful to skip from one Activity or State to another in the process without including transitions when it could be required.

Adding CodeAction

SetActivityAfterActionExecution

First, we have SetActivityAfterActionExecution method. Just click on CodeAction button in Designer toolbar for including a new Action that will call the method.

Adding CodeAction

When this method is invoked the Actions are fulfilled until the settled action, and after that, the process is set in the Activity that is specified according the parameter activityName. The process is going to be executed, and it will start on the Activity that was passed as parameter.

Adding CodeAction

SetActivityAfterActivityExecution

Second, the method SetActivityAfterActivityExecution. Analogously, you can add the CodeAction that will call this method.

Adding CodeAction

In this case, the parameter activityName is also specified, but once this method is called by the CodeAction, the execution of the rest of Actions will proceed and then, the Activity will be set. The process will continue with the specified Activity.

Adding CodeAction

SetStateAfterActionExecution

Third, we have SetStateAfterActionExecution method. It is similar to the first described method SetActivityAfterActionExecution, but the parameter stateName is specified in this case.

note

Main difference between methods SetState and SetActivity is described in this section.

Adding CodeAction

When this method is invoked, the preceding Actions and the specified one will be executed. After that, the State will be set.

Adding CodeAction

SetStateAfterActivityExecution

Finally, the method SetStateAfterActivityExecution.

Adding CodeAction

This method also works as the method SetActivityAfterActivityExecution, but using the parameter stateName. Once all the Actions in the Activity are completed, the State will be set.

Adding CodeAction

That's it! These are the methods that can be used for changing the process state within the process itself.

BasicPlugin

When installing the BasicPlugin, SetActivity and SetState actions are available as well. They also implement the methods described in the previous section, and they can be set in any Activity by adding a new Action.

info

The procedure for connecting the BasicPlugin is described in this section.

Plugin Action

SetActivity

First, we have the SetActivity action. You can select this Action in the Activity implementation section. When it is used, the SetActivityAfterActionExecution or SetActivityAfterActivityExecution method is called, depending on the Action settings. You just need to choose AfterAction or AfterActivity in the 'Edit parameter values' window. Besides, there is a mandatory field for indicating the parameter activityName.

Plugin Action

SetState

Likewise, SetState action can be used. If it is set, the SetStateAfterActionExecution or SetStateAfterActivityExecution method is called, depending on the Action settings. In this case, you can also select AfterAction or AfterActivity, but the parameter stateName must be indicated. In addition, other processes can be handled when the processId is specified. If this field has not filled out, then a transition will take place in the same process.

Plugin Action