> For the complete documentation index, see [llms.txt](https://community-test.logicnets.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/add-record.md).

# Add Record

## Description

This part offers an easy way to insert a new record into a data table in the database.

## Use

You can use this part to add new record to a data table in the database and return the row id of the inserted record. To insert multiple records use the *Add Records* part, or create a *Loop* to cycle through an array and use *Add Record* on each cycle.

## Editor Fields

| Tab   | Field Name                | Description/Use                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Type/Options | Optional/Mandatory |
| ----- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------ |
| Basic | Data object               | This is the data object in which to store the id of the inserted record. Leave this field empty if your application does not require the returned row id.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Text         | Optional           |
| Basic | Group                     | This is the name of the collection in which the data object is stored.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Text         | Optional           |
| Basic | Data source               | This is the name of the table into which the data should be saved.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | Text         | Mandatory          |
| Basic | Replace if already exists | When this checkbox is checked, the system should update the existing record if it exists instead of inserting as a new record.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Checkbox     | Optional           |
| Basic | Columns                   | <p>This is where you specify the column into which a record should be inserted and the value that should be inserted. The value to insert can be either a static value or an interpolated parameter from the session context. If you do not include the id column as one that should be added to the record, the system will automatically increment the table index.<br><strong>Tip:</strong> Use the $(...) construction to reference a variable from your application as the value to be stored in the column; for example, $(firstname).<br>You can also specify a default value if the variable is null by using $(data\_object:default-value); for example, $(company\_name:not specified). For more information on inserting null values, see the table below in the <em>Adding Null Values</em> section.</p> | Collection   | Mandatory          |
| Basic | Log data object           | <p>This is the data object that stores error messages from the execution of the database parts: add data record, get data record, update data record, delete data record, and import values. If the log data object is specified, the system will store the error message and stack trace of a database part to the object in case of errors.<br>When used by multiple database parts, the Log data object stores the cumulative list of error messages from the different parts.</p>                                                                                                                                                                                                                                                                                                                                | Text         | Optional           |
| Basic | Reset log data object     | When this is checked, the system will clear the error messages from the Log data object. Typically, this option should be checked in the first database part of a sequence of database parts.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Checkbox     | Optional           |
| Basic | Skip on error             | When this is checked, the system will skip the execution of subsequent database parts linked to the same Log data object.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Checkbox     | Optional           |

### Adding Null Values

When dealing with empty or null values in data tables, it is important to remember that there is a difference between no value and a null value. In database terms a null value is a value that does not exist: the field does not contain a value of any kind (not even a blank value). A blank value is a real value: it just happens to be a string value containing 0 characters. When you are adding or updating a value in a data table, you need to determine if you want to add an empty value or a null value and how you do it depends on what data type the field is set to receive.

The table below details what the table will save based on the data field type; for example, if the field is a text field it is expecting free format text. If you do not enter a value in the field the system will enter a blank field.

| Data Type     | Value                                                                                                                                      | If you Enter No Value/Empty String | If you Enter ‘NuLLeD’ |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------- | --------------------- |
| Text          | Free format text                                                                                                                           | Empty string                       | NULL                  |
| Number        | A number. The system will thrown an error if the number is invalid (if you enter text, for example).                                       | NULL                               | NULL                  |
| Date/DateTime | A logicnets datetime (number). The system will throw an error if you enter an invalid number/value.                                        | NULL                               | NULL                  |
| Collection    | Dataobject name, Lua data-structure code, OR $() pointing to a data object in the context that is a dataobject OR a Lua datastructure code | NULL                               | NULL                  |

Here is an example of what you might add in a field and how that will save in the data table. You can see we left the firstname field blank. It is a text field so the system entered a blank value. Birthdate is a date/datetime field and we entered NuLLeD so the system made that a null field. Income is a number field, which we left blank, so the system made that a null value.

![](https://2802811211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdFhfexCjZ5JMhwGzzywq%2Fuploads%2Fgit-blob-e53e8d08577aa219df9037f7c2a84ca3604f8d57%2Fc00d4c71-a36d-4243-998d-587d68e41d11.png?alt=media)

## Configuration Options

There are no configuration options associated with this part.

## Examples

Download and import one of the [example](/release-9/example-gallery/example-projects-for-parts/add-record-example-projects.md) projects in your workspace.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/add-record.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
