# Create object

The Create object action node adds a new [object](https://docs.appfarm.io/reference/platform-concepts/objects) in a [data source](https://docs.appfarm.io/reference/apps/data/data-sources).

## Usage

This action node is used to create a new [object](https://docs.appfarm.io/reference/platform-concepts/objects) with a set of properties defined by its [object class](https://docs.appfarm.io/reference/data-model/object-classes). The object class is set on the [data source](https://docs.appfarm.io/reference/apps/data/data-sources) that the object is created in.

To understand the differences in behavior when creating an object in a database-connected data source compared to a runtime-only data source, see [Database-connected and runtime-only data sources](https://docs.appfarm.io/reference/apps/data/data-sources#database-connected-and-runtime-only-data-sources) under [Data sources](https://docs.appfarm.io/reference/apps/data/data-sources).

When an object is created it is assigned an automatically-generated, globally unique identifier. This is stored in the **ID** property. The ID consists of 24 characters (letters and numbers) and will never change. For example, `605b5cdd5527f30cf344ab2a`.

{% hint style="info" %}
**Good to know**

Objects can also be created automatically in runtime-only, single-cardinality data sources by selecting **Auto Create** on the data source.
{% endhint %}

### Example

{% tabs %}
{% tab title="Create a new object with user data" %}
Your app is used to manage projects. You'd like for users to be able to add tasks to a project.

To do this, add a `Add task` button in the project detail view. Trigger an action when this button is clicked that runs Create object and adds a new `Task` object in a runtime-only single-cardinality data source. Use **Values on create** to set a `Project` property to the relevant project, connecting the task to the project.

Run an Open Dialog action node to display a [dialog](https://docs.appfarm.io/reference/apps/ui/views/dialog) containing [input components](https://docs.appfarm.io/ui-components#data-input) bound to other properties on the **Task** object that the user should set. Add a `Save` button to the dialog that triggers an action with a [Persist objects action node](https://docs.appfarm.io/library/action-nodes/persist-objects) to save the new object to the database.

Note that the object needs to be created before the user can enter any data.
{% endtab %}
{% endtabs %}

## Properties

<table><thead><tr><th width="236">Property</th><th>Description</th></tr></thead><tbody><tr><td><strong>Data Source</strong></td><td>Select a data source to create the object in.</td></tr><tr><td><strong>Replace Existing Object</strong></td><td><em>Available if</em> <strong>Data Source</strong> <em>is a runtime-only data source.</em><br><br>Remove any existing objects in the selected <strong>Data Source</strong> before the new object is created.</td></tr><tr><td><strong>Copies</strong></td><td><em>Available if</em> <strong>Data Source</strong> <em>is a runtime-only, many-cardinality data source.</em><br><br>Create multiple objects at once by setting the number of copies to create. All objects will have the same values as set under <strong>Values on create</strong> but each will have a unique <strong>ID</strong>.</td></tr><tr><td><strong>Set Selected</strong></td><td><em>Available if</em> <strong>Data Source</strong> <em>is a many-cardinality data source.</em><br><br>Set the newly created object as <a href="../../../reference/platform-concepts/objects#object-selection">selected</a>.</td></tr><tr><td><strong>Values on create</strong></td><td>Set values for any object class properties in the new object.</td></tr></tbody></table>
