# insert

## Description

Inserts rows of data into a dataset.

## Input / Parameter

| Name    | Description                                                             | Input Type | Default | Options | Required |
| ------- | ----------------------------------------------------------------------- | ---------- | ------- | ------- | -------- |
| dataset | The name of the dataset that is created in Services.                    | Text       | -       | -       | Yes      |
| data    | Multiple dynamic attributes with values associated with each attribute. | Object     | -       | -       | Yes      |
| extra   | The stored value that is passed to all the callbacks.                   | Any        | -       | -       | No       |

## 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

### callback

The action performed if this function runs successfully.

| Description                     | Output Type |
| ------------------------------- | ----------- |
| Returns the newly created data. | Object      |

### errorCallback

The action performed if this function does not run successfully.

| Description               | Output Type |
| ------------------------- | ----------- |
| Returns an error message. | Text        |

## Example

In this example, we will insert rows of data into a table in the local storage.

### Steps

1. Drag a `Local Table` component into the services panel in the service page and then fill the fields. For `fields` field value add `name`and `title` as object key with Text type.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-b87cd62feb0cb7e6500969aefd8b62d33a145c59%2Finsert-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-debc7272a4720ee7adaa215b701d9fe5a9ed5068%2Finsert-step-2.png?alt=media)
3. Select the event `press` and drag the `Dataset.insert` function to the event flow and fill in the parameter. For the `data` parameter, change it's type to a function / subflow and put `Conversion.toObject` inside it then add `name`, `title` as object key with `name_value`, `title_value` as it's value respectively.

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

### Result

1. The new rows of data should be stored on local storage.
