add( )

Adds a new blank item.

The add() function saves the current item and then adds a new blank item. When the editing of the new item is complete, you will need to call another function that will save the new item.

The index of the new item is one after the index of the current item, or zero if there is no current item.

Note that since the add() function begins by saving the current item, if the current item cannot be saved for any reason, such as it does not pass validation, calling the function will cause an error.

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


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

To call add() 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.

This function replaces the deprecated new() function. The deprecated function will continue to work, but will not receive updates.

Method Declaration
This method does not take any parameters
Was this helpful?