Kony Fabric console User Guide: SDKs > Kony Visualizer SDK > Invoking an Object Service > Data Transfer Objects > kony.sdk.dto.DataObject Class

kony.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 kony.sdk.dto.DataObject class has one constructor.

kony.sdk.dto.DataObject(string objectName)

Parameter Type Description
objectName string Name of object defined in the object service

Methods

The kony.sdk.dto.DataObject class includes the following methods.

addChildDataObject(child) Method

Adds another DataObject as a child.

Signature

addChildDataObject(child)

Parameters

Parameter Type Description
child kony.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

setOdataUrl(URL) Method

Specifies the Odata URL.

Signature

setOdataUrl(URL)

Parameters

Parameter Type Description
URL string The Odata URL to set.

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 be used in the query.

Signature

setSelectQueryObject(queryObject)

Parameters

Parameter Type Description
queryObject kony.sdk.dto.SelectQuery The object that contains the query.

Example

// **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.