User Guide: SDKs > Cordova (PhoneGap) SDK > Invoking an Object Service > Data Transfer Objects > voltmx.sdk.dto.DataObject Class
voltmx.sdk.dto.DataObject Class
This class represents a data object in the Object Service. An instantiation of this class is required as a parameter in many methods of the OnlineObjectService Class and the OfflineObjectService Class.
Constructors
The voltmx.sdk.dto.DataObject class has one constructor.
voltmx.sdk.dto.DataObject(string objectName)
Parameter | Type | Description |
---|---|---|
objectName | string | Name of object defined in the object service |
Fields
Field name | Type | Description |
---|---|---|
setOdataUrl | string | Specifies the Odata URL |
Methods
The voltmx.sdk.dto.DataObject class includes the following methods.
- addChildDataObject(child)
- addField(fieldName, value)
- setRecord(record)
- setSelectQueryObject(queryObject)
addChildDataObject(child) Method
Adds another DataObject as a child..
Signature
addChildDataObject(child)
Parameters
Parameter | Type | Description |
---|---|---|
child | voltmx.sdk.dto.DataObject | The DataObject to be added as a child |
addField(fieldName, value) Method
Adds a field in the data object.
Signature
addField(fieldName, value)
Parameters
Parameter | Type | Description |
---|---|---|
fieldName | string | The name of the field being added. |
value | string | The value of the added field |
setRecord(record) Method
Specifies a record in the data object.
Signature
setRecord(record)
Parameters
Parameter | Type | Description |
---|---|---|
record | JSON object | The record to be set. |
setSelectQueryObject(queryObject) Method
Sets the specific query object to use in the query.
Signature
setSelectQueryObject(queryObject)
Parameters
Parameter | Type | Description |
---|---|---|
queryObject | voltmx.sdk.dto.SelectQuery | The object that contains the query. |
Example
// **Simple Object**
var dataObject = new voltmx.sdk.dto.DataObject("objectName");
var record = {};
record.field1 = "value1";
record.field2 = "value2";
record.field3 = "value3";
//sets the record to the dataObject
dataObject.setRecord(record);
// **Complex Object**
var parentDataObject = new voltmx.sdk.dto.DataObject("parentObject");
var record = {};
record.field1 = "value1";
record.field2 = "value2";
record.field3 = "value3";
//sets the record to the parent.
parentDataObject.setRecord(record);
var childDataObject = new voltmx.sdk.dto.DataObject("childObject");
var record = {};
record.field4 = "value3";
record.field5 = "value5";
record.field6 = "value6";
//sets the record to the child
childDataObject.setRecord(record);
parentDataObject.addChildDataObject(childDataObject); // **Adding OdataUrl**
var dataObject = new voltmx.sdk.dto.DataObject("objectName");
dataObject.setOdataUrl("$filter=abc eq 123");