Obtaining Answer Data with Resolve Expressions

With NetSuite CPQ Configurator, you can use resolve expressions to fill in record fields when you set up your product and dynamically retrieve information for the configuration from answers users select on the product interface. For example, you can use answers provided by users to specify the item name or number for a material, instead of entering a fixed name in the material record and creating a separate record for every possible material. The material item name or number will depend on the answers users select on the product interface, and you can use one material record to retrieve multiple items used as materials.

To write resolve expressions in the record fields that support them—called resolvable fields—use question and answer codes separated by a forward slash and enclosed in curly braces, for example, {A/1}. If you want to retrieve only part of the information dynamically, you can add characters outside the curly braces to generate the final result, for example, {A/1}-XXX-{B/2}-XX.

Using the codes in the curly braces, NetSuite CPQ Configurator finds the answer value from the user interface or other information from the answer record, such as its code, name, label, or description.

For multiple-choice questions, the resolve expression returns the data of all selected answers, separated by commas and ordered by their sequence number.

Types of Resolve Expressions

The following table identifies the available resolve expressions. Q represents the question code, and A is the answer code. Replace Q and A with codes from your product.

Resolve Expression

Description

{Q/A}

Returns the answer value.

When questions can have only true or false as values, like checkboxes or radio buttons, this resolve expression returns true or an empty string.

{Q}

Returns the answer code.

If users select multiple answers, this resolve expression returns the codes for all selected answers, separated by commas and ordered by sequence number.

{Q:ALT_NAME}

Returns the value of the Name field from the answer record.

When users select multiple answers, this resolve expression returns the record name of all selected answers, separated by commas and ordered by sequence number.

{Q:NAME}

Returns the value of the Label field from the answer record.

When users select multiple answers, this resolve expression returns the label of all selected answers, separated by commas and ordered by sequence number.

{Q:DESC}

Returns the value of the Description field from the answer record.

When users select multiple answers, this resolve expression returns the description of all selected answers, separated by commas and ordered by sequence number.

Performing Calculations on Numbers Returned by Resolve Expressions

You can perform calculations on numbers returned by resolve expressions using basic mathematical and rounding operations to obtain the final value for resolvable fields. By performing calculations in resolvable fields, you can dynamically determine and adjust values—such as quantities, prices, and multipliers—based on answers users select on the product interface.

To perform calculations in resolvable fields, enclose resolve expressions in the calc() function and combine them with mathematical operators. For example, you can enter calc(({A/B}+{B/C})*3) in the Quantity field of an additional item record. With this resolve expression, you can dynamically determine how many of those additional items a transaction will include based on user choices.

You can use the calc() function in resolvable fields that require numbers, such as Quantity and Price fields, as well as in text fields that support resolve expressions, such as the Message field for validation records. Text fields can include multiple calc() functions combined with text.

If the resolve expression doesn't contain numbers or the calc() function is written incorrectly, the result will be NaN, which stands for not a number. You'll find more information about the issue in the console.

Supported Operations and Operators

The following mathematical operations and operators are available.

Operator Symbol

Description

()

Group calculations and specify their order. Operations inside parentheses are performed first. In the example calc(({A/B}+{B/C})*3), the addition happens before the multiplication.

+

Addition – Sums numbers.

Subtraction – Returns the difference between two numbers.

*

Multiplication – Multiplies two or more numbers.

/

Division – Divides one number by another.

**

Power – Raises a number to the power of the specified exponent. For example, calc({Q/A}**3) raises the value returned by {Q/A} to the third power.

Using Rounding Functions

When resolve expressions return decimal numbers, you can round the results using the round(), ceil(), or floor() functions inside the calc() function, for example, calc(round({Q/A}+{Q1/A1})).

Using the round() Function

The round() function rounds a value to the specified position. The syntax is:

                calc(round({Q/A}, position)) 

              

The rounding position can be a number from 1 to 100, both inclusive. 0 is the default rounding position and can be omitted. If the digit to the right of the rounding position is 5 or greater, this function rounds up the value to the nearest number or rounding position; otherwise, it rounds down the value.

The following table shows examples of the rounding operation with numeric values.

Rounding Operation

Rounded Value

calc(round(3.4))

3

calc(round(3.5))

4

calc(round(3.6))

4

calc(round(-3.4))

-3

calc(round(-3.5))

-4

calc(round(-3.5))

-4

calc(round(2.36, 1))

2.4

calc(round(4.5+3.2))

8

calc(round((4.5+3.2)/2,1))

3.9

Using the ceil() Function

The function ceil() rounds up a value to the nearest number with no decimals. The syntax is:

                calc(ceil({Q/A})) 

              

The following table shows examples of the rounding-up operation with numeric values.

Rounding-Up Operation

Rounded Up Value

calc(ceil(3.64))

4

calc(ceil(3.65))

4

calc(ceil(3.66))

4

calc(ceil(-3.64))

-3

calc(ceil(-3.65))

-3

calc(ceil(-3.66))

-3

calc(ceil(4.5+3.2))

8

calc(ceil((4.5+3.2)/2))

4

Using the floor() Function

The function floor() rounds down the value to the nearest number with no decimals. The syntax is:

                calc(floor({Q/A})) 

              

The following table shows examples of the rounding-down operation with numeric values.

Rounding-Down Operation

Rounded Down Value

calc(floor(3.64))

3

calc(floor(3.65))

3

calc(floor(3.66))

3

calc(floor(-3.64))

-4

calc(floor(-3.65))

-4

calc(floor(-3.66))

-4

calc(floor(4.5+3.2))

7

calc(floor((4.5+3.2)/2))

3

Related Topics

General Notices