Conditional Branch (Labeling Logic)

In this article we will explain how to achieve conditional branch in AForms with concrete examples. How do you do it? Attach a label on the user.

AForms uses an individual way, called “Labeling Logic”, to achieve conditional branches in the automatic quotation.

The basic idea is “When a user does something special, attach a label on him/her”.
Then, “The form controls the components by looking at the labels attached to the user”.

It would be easier to explain with actual examples, so here are some examples.

Case 1: To provide an additional option in a later item only to users who selected a specific option

For example, in the customization form of a BTO PC like Dell’s, the logic is that only users who choose Windows 10 Pro can select 32GB memory.

In this case, set up the form so that if a user chooses Windows 10 Pro as OS, AForms will attach the label “pro-edition” to the user.
Then, when selecting the memory, only if the user has the “pro-edition” label, they can choose 32GB memory.

To actually create a form in this way, enter “pro-edition” in the “Label” field of the Wondows10 Pro Option.
Then fill in the “Required Label” field of the 32GB memory Option with “pro-edition” again.

Case 2: To give a discount to users whose quoted price is above a certain amount

In this case, please use the “Price Watcher” item.
The Price Watcher is a component that monitors the quoted price and attaches a label to the user if it meets the specified criteria.
For example, if the quoted price is more than $1,000, the “large-price” label can be attached.

Adding a detail line to the quotation only when it has a specific label, you need to use “Auto Item” with “Required Labels”.
For example, the name could be “Discount”, the price could be “-50”, and the Required Labels field could be “large-price”.
Then only the users labeled “large-price” can have the $-50 details line added in the name of the discount.

Labels and Components

This information is current as of AForms2.1.0.

Components that can be used to attach labels

Also, if you write more than two labels in the “Label” field, all of them will be attached to the user.

Components that can be controlled by labels

Also, if you write more than two labels in the “Required Labels” field, the condition will not be fulfilled until all of them are attached to the user.

Label specifications

Label negation

You can use label negation in situations where labels are read. Usually, it is “if the user has label X”, but with negation, it can be “if the user does not have label X”.
To negate a label, prefix the label with “!” before the label.
If there is more than one label, for example, “A, !B, C” means “if A, and not B, and C”.

Please note that negation can only be used in situations where labels are read (when components are controlled by labels).
You cannot use negation when attaching labels by components.

0 0