HOWTO

How to remove a Transition based on a Context Variable?

If you want to remove a value from the list of reachable values based on the presence of a context variable, you can use script rule.

Let's say you want to force a change of value. If the values configured in the status_transition table allow to leave the value unchanged, you can remove it like this.

function run() {
    var toAdd = [];
    var toRemove = [];

    // If the context contains a specific boolean variable, don't
    // allow to remain on the current value.
    if (context.mustChangeStatus) {
        // The current status value is available as `statusValue`.
        // We add it to the list of values to be removed.
        toRemove.push(statusValue);
    }

    return {
        add: toAdd,
        remove: toRemove
    }
}

It is the responsibility of the REST API client to set mustChangeStatus to the boolean value true in the context.