Guide

Build models

Rules

4 min readOpen in Neblex

Rules are what make a model smart. Each rule says when these conditions are true, do these things: hide what does not apply, require what must be chosen, stop combinations that cannot be built, recommend, set values, and add prices, parts and lead time. Open them from Config › Rules.

The rule list

Filter the list by Model and search by name. Each row shows the rule's Name, Description, Type, whether it is Enabled, and when it was created and updated. From a row you can Edit the rule, switch it on or off, see its History or delete it. Click + Rule to write a new one in the Advanced Rule Builder.

The rules, filtered by model.
The rules, filtered by model.
  1. Write a new rule.

When rules run

Every enabled rule of the model is evaluated when a configuration starts and after every change. Because one rule's result can change what another rule sees (a rule sets a value, which makes another rule's condition true), the rules are evaluated again until nothing changes any more. Functions take part in the same cycle. Disabled rules are skipped.

Rule types

The Rule Type says what the rule is for, and decides which actions it can have:

Rule TypeUse it toActions
VisibilityShow only what applies and narrow the choices.Hide, Show Message, Require, Disable Option, Allow Option
ViolationStop combinations that cannot be built or sold.Violation, Show Message
RecommendationSuggest a better choice.Recommend, SetValue
DefaultingFill in sensible starting values.SetValue, Require
ComputationCalculate a value from other values.SetValue
PricingAdd to, discount or replace the price.Price
BomAdd parts to the bill of materials.Bom
Lead TimeSet or extend the lead time.LeadTime

Changing the type of a rule you have started resets its actions, after asking.

Conditions

Under Conditions, + Condition adds a comparison of an attribute with a value, and + Group adds a group whose conditions are combined with AND (all must be true) or OR (one is enough). Groups can contain groups, so any combination can be expressed.

The operators are Equals, Not Equals, Greater Than, Less Than, Greater Than or Equal, Less Than or Equal, Contains and Not Contains (part of a text), Starts With, Ends With, Includes and Not Includes (for attributes with several values), and In and Not In (one of a list, written as a JSON array such as ["Intel","AMD"]). The builder only offers the operators that make sense for the attribute's type.

The value a condition compares with can be:

  • Static: a value you type or pick, such as 64 or an option of the attribute;
  • Script: an expression calculated from the configuration, such as attributes.Width * 2. Write the expression itself, without return;
  • DQL or Advanced DQL: a value looked up from your data tables with a query.

Actions

ActionWhat it does
HideHides an attribute, or a whole section of the model's layout.
RequireMakes an attribute required, so the configuration cannot be added to a quote until it has a value.
Disable OptionMakes the chosen options of an attribute unavailable.
Allow OptionKeeps only the chosen options available and disables every other option of the attribute.
SetValueSets an attribute's value, as a fixed value, a script or a query.
RecommendRecommends a value for an attribute, with an optional message.
ViolationReports that the combination is not allowed, with your message. A configuration with a violation cannot be added to a quote.
Show MessageShows your message next to an attribute, for information.
PriceDelta ($) adds an amount (negative to subtract), Discount (%) takes a percentage off, Override ($) replaces the price.
BomAdds one or more parts with their quantity to the bill of materials.
LeadTimeMax makes the lead time at least this many days, Add adds days, Override sets it. When several rules override, the longest override wins.

Test before you save

The test panel beside the builder runs the rule without saving it. Enter attribute values under Test Attributes (JSON), for example {"Width": 600, "Color": "Black"}, and click Run Test:

  • Result says whether the rule fires.
  • Conditions shows every condition and group as true or false, with the values that were compared.
  • Actions previews what the rule would do: the parts it would add, the options it would disable, the price or lead time change.
  • Trace lists the queries and outside calls it made, with their timings.
  • Errors points to the line and column of a mistake in a script or query.

The test values are kept with the rule, so they are there next time you open it. Check conflicts compares the rule with the model's other rules and lists any that contradict it.

History, export and import

  • History lists the saved versions of a rule; roll back to an earlier one if a change did not work out.
  • Export saves the rules of a model to a file and Import reads them back, for example into another workspace. To move a whole model, use model export instead.
  • Library in the builder offers ready-made snippets to insert into scripts and queries.

For a model-wide check of rules that contradict each other, see Data Functions › Rule Conflicts.