Obtaining Answer Data with Resolve Expressions

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

To write resolve expressions in the record fields that can store them, called resolvable fields, use question and answer codes separated by the forward slash character 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.

NetSuite CPQ replaces the content between curly braces with the answer value taken from the user interface or other information from the answer record, such as its code, name, label, or description.

When working with multiple-choice questions, the resolve expression returns the data of all selected answers, separated by a comma following the answer sequence number order.

The following table identifies 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.

When users select multiple answers, this resolve expression returns the codes of all selected answers, separated by a comma following the answer sequence number order.

{Q:ALT_NAME}

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

When users select multiple answers, this resolve expression returns the record name of all selected answers, separated by a comma following the answer sequence number order.

{Q:NAME}

Returns the answer label from the Label HTML field.

When users select multiple answers, this resolve expression returns the label of all selected answers, separated by a comma following the answer sequence number order.

{Q:DESC}

Returns the answer description from the Answer Description field.

When users select multiple answers, this resolve expression returns the description of all selected answers, separated by a comma following the answer sequence number order.

Performing Calculations on Numbers Returned by Resolve Expressions

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 of resolvable fields. By performing calculations in resolvable fields, you can dynamically determine and adjust quantities, prices, multipliers, and so on, depending on answers users select on the 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 depending on users' choices.

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

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

The following mathematical operations and operators are available.

Operator Symbol

Description

()

Include calculations to be performed first. In the example calc(({A/B}+{B/C})*3), the addition will be performed before the multiplication.

+

Addition – Sums numbers.

Subtraction – Returns the difference between two numbers.

*

Multiplication – Multiplies two or more numbers.

/

Division – Divides two numbers.

**

Power – Multiplies a number by itself a certain amount of times according to the number specified by the exponent. For example, calc({Q/A}**3).

When resolve expressions return decimal numbers, you can round the value up, down, or according to the standard method using the ceil(), floor(), or round() functions enclosed in the calc() function. For example, calc(round({Q/A}+{Q1/A1})).

The round() function rounds off a value to the specified rounding 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 greater than or equal to 5, 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

The function ceil() rounds up the 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

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

NetSuite CPQ
NetSuite CPQ Overview
Installing NetSuite CPQ SuiteApps
Migrating to NetSuite CPQ SuiteApps
NetSuite CPQ Configurator
Storing Answer Options in Tables
Activating Building Blocks with Rules
Customizing Products with Scripts Using Action Records and Functions

General Notices