setFormattedValue()

The setFormattedValue() function (client-side and server-side) detects a date and time field and converts the JavaScript Date object into the string format expected by the answer record before setting the value. If used with other field types, this function behaves like setValue().

Syntax

Use this syntax for the setFormattedValue() function:

            setFormattedValue('QUESTION_CODE', 'ANSWER_CODE', new Date(date)); 

          

Return Value

The setFormattedValue() function returns undefined.

Parameters

Note:

All parameters are required.

The setFormattedValue() function accepts the following parameters:

  • QUESTION_CODE (string) - Specifies the code of the question associated with the date answer. You can find the code in the Code field on the question record.

  • ANSWER_CODE (string) - Specifies the code of the answer that stores the date. You can find the code in the Code field on the answer record.

  • new Date(date) - Specifies the date using a JavaScript Date Object.

Examples

The following examples show how to use the setFormattedValue() function.

Setting Date and Time

This example takes a standard JavaScript Date object and sets the date and time field value while automatically handling the required format.

              setFormattedValue('DATE_Q', 'DATE_A', new Date('2026-11-26T14:30:00')); 

            

Depending on the date field format, the function may set a value such as 26 November, 2026 or 6-Nov-2025 02:30 PM.

Related Topics

General Notices