insertData()
Overview
public any function insertData(
required string objectName
, required struct data
, boolean insertManyToManyRecords = false
, boolean isDraft = false
, boolean useVersioning = automatic
, numeric versionNumber = 0
, array bypassTenants
, boolean clearCaches = Defaults to whether query caching is enabled or not for this object
, numeric timeout
)
Inserts a record into the database, returning the ID of the newly created record
Arguments
Name | Type | Required | Description |
---|---|---|---|
objectName | string | Yes | Name of the object in which to to insert a record |
data | struct | Yes | Structure of data whose keys map to the properties that are defined on the object |
insertManyToManyRecords | boolean | No (default=false) | Whether or not to insert multiple relationship records for properties that have a many-to-many relationship |
isDraft | boolean | No (default=false) | Whether or not to save the record as a draft record |
useVersioning | boolean | No (default=automatic) | Whether or not to use the versioning system with the insert. If the object is setup to use versioning (default), this will default to true. |
versionNumber | numeric | No (default=0) | If using versioning, specify a version number to save against (if none specified, one will be created automatically) |
bypassTenants | array | No | Array of tenants to ignore (i.e. when the insert data wants to create a record in an alternative tenant to the current one) |
clearCaches | boolean | No (default=Defaults to whether query caching is enabled or not for this object) | Whether or not to clear caches related to the object whose record you are creating |
timeout | numeric | No | Timeout, in seconds, of the main insert DB query |
Example:
newId = presideObjectService.insertData(
objectName = "event"
, data = { name="Summer BBQ", startdate="2015-08-23", enddate="2015-08-23" }
);