Let we assume that we want to implement a simple approvement workflow, practically containing one user task with a responsible person to be approved and there are three possible outcome of the task: approves, declined or delegated. For the sake of completeness, we assume that functionalities for logging and access method control are already available, as we described them in the previous blog, The approvement process has one special information field in our example ApprovementInformation that is the information to be approved. In real case scenarios this information is best realized by an explicit smart contract.
The implementation is pretty much straightforward. The state is stored in the workflowState variable and modified by the Approve and Reject functions. Responsible person of the workflow is stored in the WorkflowResponsible variable; in current implementation only responsible person of the task can accept or decline, however everyone with a write access is allowed to delegate the task for someone else.