# loadNext

## Description

Loads the subsequent records in a dataset after loadData function was run.

## Input / Parameter

| Name    | Description                               | Input Type  | Default | Options | Required |
| ------- | ----------------------------------------- | ----------- | ------- | ------- | -------- |
| dataset | The name of the local table to be loaded. | String/Text | -       | -       | Yes      |

## Output

| Description                        | Output Type |
| ---------------------------------- | ----------- |
| Returns the formatted information. | Object      |

### Object

| Key     | Description                                                             | Output Type |
| ------- | ----------------------------------------------------------------------- | ----------- |
| success | Boolean value to denote whether the function was executed successfully. | Text        |
| message | The message to print.                                                   | Text        |
| data    | Any additional message or data to print.                                | Text        |

## Callback

### beforeCallback

The function to be executed if the subsequent records are loaded successfully.

## Example

In this example, we will load the next batch of data from the Local Table and display it in a flatlist component.

```js
Note: This example will only work after the user has created the data using `Dataset.insert` function.
```

### Steps

1. Make sure a `Local Table` component is created and filled on the services panel in the service page.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-b87cd62feb0cb7e6500969aefd8b62d33a145c59%2FloadNext-step-1.png?alt=media)
2. Drag a button component to a page in the mobile designer.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-aae38fc875d11ee9fd7bb14daea80072540c86ce%2FloadNext-step-2.png?alt=media)
3. Drag a `flatlist` component to a page in the mobile designer, and drag a `label` component into the `flatlist` component.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-100438a96526e4423d19cbc0e3af396a25254e6a%2FloadNext-step-3.png?alt=media)
4. Fill the `flatlist` component property in the page and fill the `label` component property in the `flatlist` component. Make sure the `label` component field value matches the key of the data that is being stored in the local table.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-5ca570b13c8763d8e3fbb12cd2153c34add6f00d%2FloadNext-step-4.png?alt=media)
5. Select the event `press` and drag the `Dataset.loadNext` function to the event flow. Fill in the parameters of the function.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-03f93b9683b1d9b49c08efeab9c307cdd64081ec%2FloadNext-step-5.png?alt=media)

### Result

1. The next batch of data should be loaded from the local table and displayed in the flalist component.
