Constraints

The main purpose of a constraint is to introduce logic into Billing screens. For example, if an account is on hold, then the Put On Hold button should be disabled. The constraints are declared in the <actions> section of an XML file.

The constraint structure is the following:

<constraint id="<constraint_id>" ele="<target_id>">
   <action>
    <condition>
   </action>
  </constraint>

Constraint elements

  1. <constraint_id>

    The constraint unique identifier. We recommend that you use a descriptive identifier.

  2. <target_id>

    A target is an ID of a screen element that is subject to condition. A condition can be applied to:

    • ele="<element_id>" – a screen declared elements – buttons, fields, links and the like.
    • ele="tree:<branch_id>" – a branch of the navigation tree. All branches and leaves included are subject to condition too.
    • ele="tree:<leaf_id>" – a leaf of the navigation tree.
    • ele="<grid_id>:null" – a grid of a screen. All rows and cells included are subject to condition too.
    • ele=""<grid_id>:<row_id>" – a row of a grid.

    A number of targets in a constraint is not limited. Each target element is quoted and separated by comma.

    Example:

    <constraint id="hideExternal" ele="SetExternal:ExternalUnit", "RestoreDefault", "add">
     <action>
      <condition>
     </action>
    </constraint>
  3. <action>

    An action that is to be performed over a target if a condition is True. If the condition is False, nothing happens. Billing supports the following actions:

    • enable – makes a target enabled.
    • disable – makes a target disabled, grayed.
    • hide – hides a target.
    • show – makes a target visible.
    • readonly – forbids a target editing.
    • required – makes a target mandatory.
    • optional – makes a target optional.

    Note: Input elements cannot be hidden or shown.

    Example:

    <constraint id="hideExternal" ele="SetExternal:ExternalUnit", "RestoreDefault">
     <hide>
      <condition>
     </hide>
    </constraint>
  4. <condition>

    Condition is a Boolean expression. It is evaluated according to comparison operator rule and results in one of two values True or False. It can be took to the following parts:

    • <element_id> - identifier of one of a screen declared elements (buttons, parameters, links and the like) that to be compared .
    • "comparison_operator" - defines a rule of comparing. The following operators are supported:
      • "==" – equal;
      • "!=" – not equal;
      • "<" – less than;
      • ">" – greater than;
    • "<element_id>" or "constant" – identifier of one of a screen declared elements or constant that to be compared against.

    One constraint can contain multiple conditions joined by logic operators:

    • AND operator:

      <constraint id="grayedExternal" ele="SetExternal:ExternalUnit">
       <hide>
        ActualStatus "!=" "1"
        ActualStatus "!=" "4"
       </hide>
      </constraint>
    • OR operator

      <constraint id="hideActivate" ele="Activate">
       <hide>
        AccStatus "!=" "1"
       </hide>
       <hide>
        AccStatus "!=" "2"
       </hide>
       <hide>
        AccStatus "!=" "3"
       </hide>
      </constraint>

Combining constraints

Billing constraints are simplex operations - an action is performed if condition is True, otherwise nothing happens. You can construct bidirectional one combining two opposite constraints.

<constraint id="hideActivate" ele="Activate">
 <hide>
  AccStatus "!=" "1"
 </hide>
 </constraint>
<constraint id="showActivate" ele="Activate">
 <show>
  AccStatus "==" "1"
 </show>
 </constraint>
CloudBlue, an Ingram Micro business, uses cookies to improve the usability of our site. By continuing to use this site and/or logging in you are accepting the use of these cookies. For more information, visit our Privacy Policy.