rbv_api.createRecord()
Purpose
This Object Script method creates new object records from the values passed in. The Object
Script API invokes triggers on create, on update and on delete the same way as the Platform
user interface does. The ID of a newly created record is available for other triggers in
update chain through the shared value, newID_objectName, that can be
retrieved using getSharedValue().
Formulas used in Object Script triggers can include other API methods and regular Platform template functionality, such as loops. Object Script methods have no effect if called outside of update triggers.
Syntax
rbv_api.createRecord(objName, arr)
Parameters
objName
Integration name of the type of object to create
arr
JavaScript array of field name/value pairs (required fields must be supplied). For multiple records, provide multiple array of field name/value pairs.
Return value
Object ID of the newly created record
Execution context and permissions
This method does not perform its own object-level Create permission check. When called from a server-side script, it runs with the Server API role, which has all administrator permissions. The initiating user's Create permission is not independently enforced by this API call. If the script must enforce that user's Create permission, check authorization in the script before calling this method.
Example
The following creates a related record:
var x = new Array();
x["amount"]=1000;
x["R477842"]={!id};
x["name"]="API Created";
var newId = rbv_api.createRecord("item", x);
rbv_api.print("Created record with id: "+newId);
The following creates multiple related records:
var objs = [];
for (var i=0; i < 10; i++) {
var obj = new Object();
obj['name'] = 'API Rec1' + i;
obj['fld'] = 'Modify';
objs.push(obj);
}
rbv_api.createRecord("ServerSideAPIBulk", objs);
The following creates a Communication Log record:
var a = new Array();
a["name"] = "Next Action Changed";
a["body"] = "Test body string";
a["commParent"] = {!id};
rbv_api.createRecord("COMMLOG", a);