State Machines: Advanced Workflows

Earlier this week we’ve shared our introductory post about our latest feature, State Machines, detailing all it’s basic features and user interface. Today we’re diving a little deeper into the feature, detailing and exemplifying more advanced configurations and possibilities that it contains.

In this post we’re going to cover In & Out Behaviours, Assignments, Comments, Automatic Transitions, Blocked Attributes/Operations and External Data Sources.

"Idea App" example

For the purpose of exemplifying these advanced features in the same context, we’ll be using a simple app concept we called “Idea Sharing” app. The goal of this app is to simply allow its users to submit new ideas to the team, so that they can be validated, by a specific group, and later approved, or rejected, by the CEO. The key workflow we want to focus is related to the entity “Idea”, that should follow this simple state flow:

 

In & Out Behaviours

In & Out Behaviours are a very useful tool to perform operations when a state in reached or abandoned. By giving the developer the possibility to add his custom code when a state is reached, or when a state is abandoned, we allow for a much simpler and intuitive process.

One example of the usefulness of this feature is the measurement of how much time has an entity spent in a given state. Let’s say we would like to measure how much time an “Idea” has spent in the “In Validation” state. After creating the attributes “ValidationStart” and “ValidationEnd” (to record the initial and end times), we would simply need to add a C# expression in the respective fields, like so:

– On State In

– On State Out:

With these attributes and these simple C# expressions, we now have the ability to use this data to perform all sorts of operations, like keeping track of the amount of time each idea spends in a given state.

Assignments

One of the most common workflow features of a typical state machine is the assignment of an entity to a user, or a group of users, based on the state it’s in.

Example: one clear use of the “assign” feature is the assignment of the “Idea” to the “Validation Group”, when it has reached the “In Validation” state. This way we guarantee that when an “Idea” is submitted by its author, it will only be available to the “Validation Group”, that will then decide if the idea moves on to the “In Approval” state, or not..

To achieve this we simply need to add the following code to our “Assign to” field of the “In Validation” state.

 

Comments

When dealing with typical approval workflows, one key business component of a decision, or transition, is the ability to add a comment, or approval/denial note to support the decision. With that in mind, we’ve developed a simple “Comment” feature built-in our State Machine builder that allows you to easily add a comment box at the time of a decision.

There are three available options to deal with this feature:

  • Don’t include comment box;
  • Include comment box, make it optional;
  • Include comment box, make it mandatory;
 
Example: a common use of this feature is in validation-required states, where a decision has to be made. Using our “Idea App” example, this feature would be particularly useful in the “Awaiting Validation” state, where we could force the “Validation Group” to add a comment when an idea is being validated, providing a justification for the decision. 

Automatic Transitions

Transitions are most commonly executed after a user action. Whether it is the submission of an expense, or a vacation request, usually the transition from one state to another is dependent on an action from a user.

Automatic transitions are the feature that allows you to automate a state transition, based on input data, without the need for an action/decision.

Example: Let’s imagine a scenario where the company’s CEO submits an idea. Because he is the only responsible for approving or rejecting validated ideas, the “In Approval” state becomes unnecessary. To perform this automatic transition, we would simply need to add the following code to the “In Approval” state, so that it flows automatic to the “Approved” state, if the author of the idea is the CEO:

Blocked Attributes & Operations

When dealing with approval workflows, one particular need is the ability to easily block all (or some) attributes of an entity, so that the next user is only allowed to interact with the unblocked ones. These options are very useful when we wish to fully control what each user is able to do in a given entity, when it reaches a specific state.

Our “Blocked Attributes & Operations” feature was built exactly to accelerate this sort of developments, allowing you to block all attributes and/or all operations within an entity, with just one click.

Example: 

Following our “Idea App” example, let’s focus on the final states “Approved” and “Rejected”. These states mean that the process has reached its end and, therefor, should not be editable in any way. By making use of the features “Disable all attributes?” and “Disable All Operations?”, we make sure that when an “Idea” reaches either of the final states, the input information is locked and the entire document becomes read-only. Here’s how:

 

External Data Sources

External data sources are one of the most relevant features of our development platform and, for that reason, it  wouldn’t make sense not to allow entities from external data sources to also be controled by a state machine.

With the inclusion of this option, we guarantee that you’ll be able to add and control states for any entity used in your application, whether it be from the internal, or from external data sources.

Try our development platform today

If you want to know more about our platform, you can try our free version right here, or get in touch with us and schedule an introduction demo that specially for you.