sresolve()
The sresolve() function (client-side and server-side) resolves a value from a resolve expression {Q/A} and, if possible, converts the resolved value to a number. Otherwise, the function returns a string.
You can use the calc() function to perform calculations on numbers returned by resolve expressions. For more information about resolve expressions, see Obtaining Answer Data with Resolve Expressions.
Unlike nResolve(), it won't return an error if the resolved value isn't a number.
Syntax
Use this syntax for the sresolve() function:
sresolve(resolveExpression, enableStrictMode, customErrorMessage);
See detailed information about the syntax for each parameter:
sresolve('{QUESTION_CODE/ANSWER_CODE}', true | false, 'Custom error message');
Return Value
The sresolve() function returns the resolved value as a number,if possible, or a string. If enableStrictMode is true, it returns null or the custom error message when one ore multiple resolve expressions returns an empty string.
Parameters
The resolveExpression parameter is required.
The sresolve() function accepts the following parameters:
-
resolveExpression(string) - The resolve expression in the format{QUESTION_CODE/ANSWER_CODE}. You can find the codes in the Code field on the question and answer records. -
enableStrictMode- Iftrue, the function returnsnullor the custom error message when one or more resolve expressions return an empty string. -
customErrorMessage(string) - A custom error message to display when one or more resolve expressions return an empty string. This parameter is available only when theenableStrictModeparameter is set totrue.
Examples
The following examples show how to use the sresolve() function.
Converting a Resolved Value to a Number
This example retrieves the answer value for the quantity associated with the LAMP question and converts it to a number if possible.
let resolvedValue = sresolve('{LAMP/QTY}');
console.log(resolvedValue);