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.
The kony.sdk.dto.DataObject class has one constructor.
| Parameter | Type | Description | 
|---|---|---|
| objectName | string | Name of object defined in the object service | 
The kony.sdk.dto.DataObject class includes the following methods.
Adds another DataObject as a child.
addChildDataObject(child)
| Parameter | Type | Description | 
|---|---|---|
| child | kony.sdk.dto.DataObject | The DataObject to be added as a child | 
Adds a field in the data object.
addField(fieldName, value)
| Parameter | Type | Description | 
|---|---|---|
| fieldName | string | The name of the field being added. | 
| value | string | The value of the added field | 
Specifies the Odata URL.
setOdataUrl(URL)
| Parameter | Type | Description | 
|---|---|---|
| URL | string | The Odata URL to set. | 
Specifies a record in the data object.
setRecord(record)
| Parameter | Type | Description | 
|---|---|---|
| record | JSON object | The record to be set. | 
Sets the specific query object to be used in the query.
setSelectQueryObject(queryObject)
| Parameter | Type | Description | 
|---|---|---|
| queryObject | kony.sdk.dto.SelectQuery | The object that contains the query. | 
// **Simple Object**
var dataObject = new kony.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 kony.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 kony.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 kony.sdk.dto.DataObject("objectName");
dataObject.setOdataUrl("$filter=fieldname eq value");
            | Copyright © 2020 Kony, Inc. All rights reserved. |