Advanced workflows

cplace's workflow manager is also capable of more complex operations like attribute validation and highlighting when triggering a transition. This section provides a deep dive in some of the advanced functions.

Using custom validators

The "check custom validators" option in the transition editor provides the option to run validators (pro code & low code) with the attribute values of the state the transition is triggering to, i.e. the target state of the transition.

This not only validates the post transition state but also gives the user visual feedback of why the transition could not be executed successfully by highlighting the attributes whose validators failed. Setting this up however is a little bit more complicated as the validators most likely will have to respect the state of the workflow. cplaceJS validators are suited well for that kind of task as they can be defined as the workflow is built.

A validator which checks a boolean flag which needs to be set for transition to the next state could look like this for example:

var state = page.get('workflow');
if(state === 'nextState') {
  if(!page.get('approval')) {
    return messages.get('approval_needed', page.getName());
return null;

When writing such validators you should keep in mind that they are called with the attribute values from the transitioned state. So if you're transitioning from previousState to nextState you have to think a step ahead, which can be a little confusing sometimes - especially when data structures get complex.