evalRule()
The evalRule() (client-side and server-side) function parses and evaluates NetSuite CPQ rules against the current configuration. For more information about rules, see Activating or Hiding Building Blocks with Rules.
Syntax
Use this syntax for the evalRule() function:
evalRule('rule');
Note:
The rule string must follow the required format, for example, QA/A1&QB/A2.
Return Value
The evalRule() function returns either true if the rule conditions are met, or false if they aren't.
Parameters
The evalRule() function accepts a rule as a required string parameter.
Examples
The following examples show how to use the evalRule() function.
Evaluating a Rule
This example evaluates whether the laptop screen is larger than 14 inches and logs a message accordingly. The rule being checked is LAPTOP_SCREEN/SIZE[>14].
if (evalRule('LAPTOP_SCREEN/SIZE[>14]')) {
console.log("The laptop's screen is larger than 14 inches.");
} else {
console.log("The laptop's screen is 14 inches or smaller.");
}