Search.../

setFieldValues( )

Updates the values of a set of fields in the current item.

Description

The setFieldValues function sets the value of a set of fields in the current item. Setting the field values fires one onItemValuesChanged event when the page elements connected to the fields have been updated with the new values.

Calling setFieldValues() on a read-only dataset causes an error.

Note:

A dataset needs to load its data before you call its setFieldValues() function. Usually a dataset finishes loading a short time after the page it is on finishes loading. So if you call setFieldValues() inside the page’s onReady() event handler, the dataset might not be ready yet.

To call setFieldValues() as soon as possible after a page loads, use the dataset's onReady() function inside the page’s onReady() event handler to ensure that both the page and the dataset have finished loading.

Syntax

function setFieldValues(fieldValues: Object): void

setFieldValues Parameters

NAME
TYPE
DESCRIPTION
fieldValues

Object

A map of field keys to new values.

Returns

This function does not return anything.

Return Type:

void

Related Content:

Was this helpful?

Set several fields' values

Code Example

Copy Code
1$w("#myDataset").setFieldValues( {
2 "title": "New Title",
3 "name": "New Name"
4} );
Set several fields' values when the page loads

Code Example

Copy Code
1$w.onReady( () => {
2 $w("#myDataset").onReady( () => {
3 $w("#myDataset").setFieldValues( {
4 "title": "New Title",
5 "name": "New Name"
6 } );
7
8 } );
9
10} );