Updates the value of a field in the current item.
The setFieldValue
function sets the value of a field in the current item.
Setting a field value fires an onItemValuesChanged
event when the page
elements connected to the field have been updated with the new value.
Setting the value of a field in a dataset item does not immediately set
that value in the collection that the dataset is connected to. You still
need to call the dataset save()
function or any other function that
performs a save to have the new value reflecting in the collection.
Calling setFieldValue()
on a read-only dataset causes an error.
Note:
A dataset needs to load its data before you call its setFieldValue()
function.
Usually a dataset finishes loading a short time after the page it is on finishes
loading. So if you call setFieldValue()
inside the page’s onReady()
event handler, the dataset might not be ready yet.
To call setFieldValue()
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.
The field ID of the field to update.
The new value.