Precondition Matching

abstract Precondition Matching is a powerful feature of Flowcharts.
When dealing with complex flows, Precondition Matching allows us to separate the setup steps from the business rules.
A path can define its preconditions via the Condition node. When a path is to be executed, Flowcharts will check if there are any conditions. If these conditions are on state attributes, Flowcharts will look for other paths which can satisfy the precondition. To satisfy, the other path should have an Outcome node with an expression which satisfies the precondition.

If Create Coupon has a Condition $product.exists==true?
And Create Product has an Outcome $product.exists=true
Then: When we Automate Create Coupon, we will see the sequence of paths. When Create Coupon is run, Create Product will run first and then Create Coupon will run.
We call paths which run as part of precondition matching as prepaths. In this case Create Product is a prepath.
info .exists has a special meaning during precondition matching. Use .exists to signal the creation of an entity in the system.
In any CRUD application, the path that Creates the entity should end in an Outcome node with $entity.exists=true
In other paths, to ensure the entity has been created, use a precondition of $enity.exists? in a Condition node.
Example 2: User Re-registration should fail

Constant Attribute Condition matching is ensured in Precondition Matching also:

Screen Navigation Management

Login Management

Multiple Entity Instances

To have 2 (or more) entity instances of the same type in a single path, add a number suffix. Eg. $user and $user2
Eg. Make $user manager of $user2
The suffix just lets Flowcharts know that these entities should be treated as different instances in this path. The suffix is ignored while matching prepaths. Notice how Create User path is traversed twice - once for $user and again for $user2.

Path Data

Only the Dataset attached to the last path will be honored. Any datasets attached to prepaths with be ignored.