For the complete documentation index, see llms.txt. This page is also available as Markdown.

Create object

The Create object action node adds a new object in a data source.

Usage

This action node is used to create a new object with a set of properties defined by its object class. The object class is set on the data source 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 under 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.

Good to know

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

Example

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 containing input components 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 to save the new object to the database.

Note that the object needs to be created before the user can enter any data.

Working with schemas

Create Object can target an action variable of type schema. When the target is a schema, the action node creates a new object in the schema structure and the Values on create section maps values onto the schema's properties.

To populate an array property in a schema, you can data bind it to a data source. The objects from the source are created as elements within the schema array. See an example setup in the image below.

Creating objects in an array using a databinding to a data source.

When schema data needs to be written to the database, the property values from the schema can be mapped onto an action data source backed by an object class using Values on create. Only schemas with overlapping properties are shown as mapping candidates. Once the data is mapped onto the action data source, it can be persisted with the Persist Objects action node.

There are a few behaviors specific to schemas:

  • On an array-typed schema property, Replace existing object defaults to false. New objects are appended to the array rather than replacing its contents.

  • On a cardinality-one schema, running Create Object a second time raises an error rather than silently replacing the existing object. Delete the existing object first if you need to replace it.

  • Create Object is not available on primitive schema properties. Primitive values are created automatically when the parent object is created. Use the update object action node to modify their value.

Properties

Property
Description

Data Source

Select a data source to create the object in.

Replace Existing Object

Available if Data Source is a runtime-only data source. Remove any existing objects in the selected Data Source before the new object is created.

Copies

Available if Data Source is a runtime-only, many-cardinality data source. Create multiple objects at once by setting the number of copies to create. All objects will have the same values as set under Values on create but each will have a unique ID.

Set Selected

Available if Data Source is a many-cardinality data source. Set the newly created object as selected.

Values on create

Set values for any object class properties in the new object.

Last updated

Was this helpful?