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

NameTypeRequiredDescription
objectNamestringYesName of the object in which to to insert a record
datastructYesStructure of data whose keys map to the properties that are defined on the object
insertManyToManyRecordsbooleanNo (default=false)Whether or not to insert multiple relationship records for properties that have a many-to-many relationship
isDraftbooleanNo (default=false)Whether or not to save the record as a draft record
useVersioningbooleanNo (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.
versionNumbernumericNo (default=0)If using versioning, specify a version number to save against (if none specified, one will be created automatically)
bypassTenantsarrayNoArray of tenants to ignore (i.e. when the insert data wants to create a record in an alternative tenant to the current one)
clearCachesbooleanNo (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
timeoutnumericNoTimeout, 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" }
);