getCurrentItem( )

Returns the current item.


The getCurrentItem() function returns an object whose key:value pairs are the field IDs and field values of the current item, including all hidden fields. Fields that do not have a value are omitted from the returned object.

When called on a write-only or read & write dataset, getCurrentItem() returns the unsaved state of the current item.

Returns null or undefined if the dataset:

  • Is filtered to not match any items in the collection.
  • Is empty.
  • Has not loaded yet.


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

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

If the current item is changed from a non-dataset source, such as by selecting a row in a table connected to a dataset or clicking a button set to advance to the next item in a dataset, the dataset's current item is not updated immediately. Therefore, to get the dataset's new current item, call getCurrentItem() in the dataset's onCurrentIndexChanged() event handler. Do not use the events of the non-dataset source, such as onRowSelect or onClick, to call getCurrentItem() because they will fire before the dataset's current item is updated.


function getCurrentItem(): Object

getCurrentItem Parameters

This function does not take any parameters.


The current item, or null if there is no current item.

Return Type:


Was this helpful?

Get the dataset's current item

Copy Code
1let itemObj = $w("#myDataset").getCurrentItem();
4 * {
5 * "_id": "fcec780a-3e37-4b64-8a66-37c552c53f99",
6 * "_owner": "f6c0f9c3-a62d-7e9f-g58d-943829af244d9",
7 * "_createdDate": "2017-05-01T17:19:03.823Z",
8 * "_updatedDate": "2017-05-01T17:19:10.477Z",
9 * "title": "Dr. ",
10 * "name": "B",
11 * "link-dynamic-name": "/myCollection/B"
12 * }
13 */
Get the dataset's current item when the page loads

Copy Code
1$w.onReady( () => {
2 $w("#myDataset").onReady( () => {
3 let itemObj = $w("#myDataset").getCurrentItem();
5 } );
7} );
9/* itemObj:
10 *
11 * {
12 * "_id": "fcec780a-3e37-4b64-8a66-37c552c53f99",
13 * "_owner": "f6c0f9c3-a62d-7e9f-g58d-943829af244d9",
14 * "_createdDate": "2017-05-01T17:19:03.823Z",
15 * "_updatedDate": "2017-05-01T17:19:10.477Z",
16 * "title": "Dr. ",
17 * "name": "B",
18 * "link-dynamic-name": "/myCollection/B"
19 * }
20 */
Get the dataset's current item when an item is clicked in a repeater

This example demonstrates how to get an item's details using the at() function. We use this function to establish context when a repeater container is clicked.

Copy Code
1$w.onReady( function () {
2 $w("#repeatedContainer").onClick( (event) => {
3 let $item = $;
4 let clickedItemData = $item("#myDataset").getCurrentItem();
5 } );
6} );