record_create()
Create a new record in a table.
Syntax
record_create(table, data, opts?)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
table |
string | yes | Table name or database table id. |
data |
array | yes | Field values keyed by field id (e.g. ["name" => "Acme"]). |
opts |
array | no | Options. ["silent" => true] suppresses notifications to the new record's followers. |
Returns
The created record as an array (fields keyed by field id, plus _meta with the new id and title).
Example
$new = record_create("contacts", [
"name" => "Jane Doe",
"email" => "jane@example.com",
"status" => "lead"
]);
sys_log("Created contact #" . $new["_meta"]["id"]);
Example output
[
"name" => "Jane Doe",
"email" => "jane@example.com",
"status" => "lead",
"_meta" => ["id" => 412, "title" => "Jane Doe"]
]
Notes
- Don't include the key (id) field in
data— it's assigned automatically. - The change is recorded in activity history but does not trigger other automations.
["silent" => true]mutes follower notifications only; users assigned via a user field are still notified. See Notifications.
See also: record_update(), record_get()