# dataFromString

## Description

This will replace all the existing records in the local table with the new records. The values inserted must be in a JSON format.

## Input / Parameter

| Name    | Description                                                     | Input Type  | Default | Options | Required |
| ------- | --------------------------------------------------------------- | ----------- | ------- | ------- | -------- |
| dataset | The name of the local table to be edited.                       | String/Text | -       | -       | Yes      |
| string  | The values to be inserted in the local table.                   | Array/List  | -       | -       | Yes      |
| append  | Inserts the specified content at the end of a selected element. | String/Text | -       | -       | No       |
| extra   | Extra parameters stored and passed to callback.                 | Any         | -       | -       | No       |

## Output

| Description                                     | Output Type |
| ----------------------------------------------- | ----------- |
| Returns the list of records in the local table. | Array/List  |

## Callback?

### callback

The function to be executed if the local table is updated with the new records successfully.

### errorCallback

The function to be executed if the local table is not updated with the new records successfully.

## Video

Coming Soon.

## Example

The user wants to replace all the existing records in the local table with the new ones.<br>

### Step

1. Call the function "dataFromString", set the dataset and set the function "jsonDecode" to string.\
   dataset: l\_customer\
   string: jsonDecode<br>

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-250163ddfaff9259914ef4a1d38575228624f7f7%2FdataFromString-step-1.png?alt=media)
2. Call the function "toArray" and set the function "toObject" to string and define the id and code.\
   string: toObject\
   id: 1\
   code: C00013\
   id: 2\
   code: C00014\
   id: 3\
   code: C00015\
   id: 4\
   code: C00016<br>

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

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

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

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

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

### Result

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-9b1f0e13600968e316138cf02e64fb7382fddad1%2FdataFromString-result-1.png?alt=media)<br>

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-87bdc7eeae72e4700b28442ccab1667c0e38b0b0%2FdataFromString-result-2.png?alt=media)

## Links
