Provides methods that perform operations acting on the Kony Fabric endpoint, including basic CRUD, metadata, and binary-related functions. An instance of OnlineObjectService is returned by the getObjectService Method when the second parameter specifies {"access":"online"}.
The following methods are used by the OnlineObjectService class and its instantiations.
Creates an object in the Kony Fabric endpoint.
create(options, successCallback, failureCallback);
Parameter | Description |
---|---|
options |
JSON object with the mandatory parameter "dataObject" which must be an instance of the kony.sdk.dto.DataObject Class |
successCallback |
Function invoked when the operation succeeds, with the primary key of the created object |
failureCallback | Function invoked when the operation fails, with cause of failure |
var objSvc = kony.sdk.getCurrentInstance().getObjectService("serviceName", { "access": "online" }); var dataObject = new kony.sdk.dto.DataObject("ObjectName"); dataObject.addField("field1", "value1"); var options = { "dataObject": dataObject }; objSvc.create(options, function(response) { kony.print("Record created: " + JSON.stringify(response)); }, function(error) { kony.print("Error in record creation: " + JSON.stringify(error)); } );
Note: When using object services for SAP, the general norm is to have character field values stored in upper case. However, if you need to pass in mixed/lower case values for an SAP field, ensure that this field is designated as mixed case in the SAP Add-in LDB workbench.
Updates an object in the Kony Fabric endpoint.
update(options, successCallback, failureCallback);
Parameter | Description |
---|---|
options | JSON object with the mandatory parameter "dataObject", which must be an instance of the kony.sdk.dto.DataObject Class |
successCallback |
Function invoked when the operation succeeds, with the number of records updated |
failureCallback | Function invoked when the operation fails, with cause of failure |
var objSvc = kony.sdk.getCurrentInstance().getObjectService("serviceName", { "access": "online" }); var dataObject = new kony.sdk.dto.DataObject("ObjectName"); dataObject.addField("field1", "value1"); dataObject.addField("primaryKeyField", "value"); var options = { "dataObject": dataObject }; objSvc.update(options, function(response) { kony.print("Record updated: " + JSON.stringify(response)); }, function(error) { kony.print("Error in record update: " + JSON.stringify(error)); });
Deletes an object in the Kony Fabric endpoint.
deleteRecord(options, successCallback, failureCallback);
Parameter | Description |
---|---|
options | JSON object with the mandatory parameter "dataObject", which must be an instance of the kony.sdk.dto.DataObject Class |
successCallback |
Function invoked when the operation succeeds, with the number of records deleted |
failureCallback | Function invoked when the operation fails, with cause of failure |
var objSvc = kony.sdk.getCurrentInstance().getObjectService("serviceName", { "access": "online" }); var dataObject = new kony.sdk.dto.DataObject("ObjectName"); dataObject.addField("field1", "value1"); dataObject.addField("primaryKeyField", "value"); var options = { "dataObject": dataObject }; objSvc.deleteRecord(options, function(response) { kony.print("Record deleted: " + JSON.stringify(response)); }, function(error) { kony.print("Error in record deletion: " + JSON.stringify(error)); });
Performs a custom operation on an object in the Kony Fabric endpoint.
customVerb(verbName, options, successCallback, failureCallback);
Parameter | Description |
---|---|
verbName | Name of the custom verb defined in the Kony Fabric console |
options | JSON object with the mandatory parameter "dataObject", which must be an instance of the kony.sdk.dto.DataObject Class |
successCallback |
Function invoked when the operation succeeds |
failureCallback | Function invoked when the operation fails, with cause of failure |
var objSvc = kony.sdk.getCurrentInstance().getObjectService("serviceName", { "access": "online" }); var dataObject = new kony.sdk.dto.DataObject("ObjectName"); dataObject.addField("field1", "value1"); dataObject.addField("primaryKeyField", "value"); var options = { "dataObject": dataObject }; objSvc.customVerb("verbName", options, function(response) { kony.print("Custom operation performed: " + JSON.stringify(response)); }, function(error) { kony.print("Error in custom operation:" + JSON.stringify(error)); });
Fetches an object from the server.
fetch(options, successCallback, failureCallback);
Parameter | Description |
---|---|
options | JSON object with the mandatory parameter "dataObject", which must be an instance of the kony.sdk.dto.DataObject Class. This instance must have the property selectQueryObject, which is an instance of kony.sdk.dto.SelectQuery, in order to fetch records based on the given criteria. |
successCallback |
Function invoked when the method succeeds, with the number of records fetched |
failureCallback | Function invoked when fetch fails, with cause of failure |
var objSvc = kony.sdk.getCurrentInstance().getObjectService("serviceName", { "access": "online" }); var dataObject = new kony.sdk.dto.DataObject("ObjectName"); var odataUrl = "$filter=fieldname eq value"; dataObject.odataUrl = odataUrl; var options = { "dataObject": dataObject }; objSvc.fetch(options, function(response) { kony.print("record: " + response["records"]); }, function(error) { kony.print("Failed to fetch: " + JSON.stringify(error)); });
Gets the metadata associated with the objects defined in the service from the server.
getMetadataOfAllObjects(options, successCallback, failureCallback);
Parameter | Description |
---|---|
options | JSON object with the optional parameter "getFromServer" |
successCallback |
Function invoked when the operation succeeds |
failureCallback | Function invoked when the operation fails, with cause of failure |
var objSvc = kony.sdk.getCurrentInstance().getObjectService("serviceName", { "access": "online" }); objSvc.getMetadataOfAllObjects({}, function(response) { kony.print("Metadata: " + JSON.stringify(response)); }, function(error) { kony.print("Error in metadata: " + JSON.stringify(error)); });
Gets the metadata associated with an object defined in the service from the server.
getMetadataOfObject(objectName, options, successCallback, failureCallback);
Parameter | Description |
---|---|
objectName | The name of the desired object as defined in the service |
options | JSON object with the optional parameter "getFromServer" |
successCallback |
Function invoked when the operation succeeds, with the number of records gotten |
failureCallback | Function invoked when the operation fails, with cause of failure |
var objSvc = kony.sdk.getCurrentInstance().getObjectService("serviceName", { "access": "online" }); objSvc.getMetadataOfObject("objectName", {}, function(response) { kony.print("Metadata: " + JSON.stringify(response)); }, function(error) { kony.print("Error in metadata: " + JSON.stringify(error)); });
Parameter | Description |
---|---|
options (Refer the Options below) | JSON object with the mandatory parameter dataObject, which is an instance of the kony.sdk.dto.DataObject Class, |
fileDownloadStartedCallback | Callback to be invoked after file download start, this callback is optional. |
chunkDownloadCompletedCallback | callback invoked after each successful chunk download, this is invoked only when streaming is true. This callback is mandatory if streaming is true. |
fileDownloadCompletedCallback | Callback invoked after successful file download, with the file path. This is manditory if streaming is false. |
downloadFailureCallback | Callback invoked in case of download failure. |
Key | Value | Mandatory | Default Value |
dataObject | Instance of kony.sdk.dto.DataObject | Yes | - |
streaming | Boolean flag to determine whether the data needed to be given to chunks or a file after download. | No | false |
queryParams | provision for user to specify additional query params that need to be sent in the download call. | No | null |
headers | Provision for sending custom headers | No | null |
Parameter | Description |
---|---|
options (Refer the Options below) | JSON object with the mandatory parameter dataObject, which is an instance of the kony.sdk.dto.DataObject Class, |
binaryAttributeName | Binary field name in the object. |
fileDownloadStartedCallback | Callback to be invoked after file download start, this callback is optional. |
chunkDownloadCompletedCallback | callback invoked after each successful chunk download, this is invoked only when streaming is true. This callback is mandatory if streaming is true. |
fileDownloadCompletedCallback | Callback invoked after successful file download, with the file path. This is manditory if streaming is false. |
downloadFailureCallback | Callback invoked in case of download failure. |
Key | Value | Mandatory | Default Value |
dataObject | Instance of kony.sdk.dto.DataObject | Yes | - |
streaming | Boolean flag to determine whether the data needed to be given to chunks or a file after download. | No | false |
queryParams | provision for user to specify additional query params that need to be sent in the download call. | No | null |
headers | Provision for sending custom headers | No | null |
Gets binary content on the server.
getBinaryContent(options, successCallback, failureCallback);
Parameter | Description |
---|---|
options | JSON object with the mandatory parameter "dataObject", which is an instance of the kony.sdk.dto.DataObject Class, and "binaryAttrName", which is the binary field name in the object |
successCallback |
Function invoked when the operation succeeds, with the number of records gotten |
failureCallback | Function invoked when the operation fails, with cause of failure |
var objSvc = kony.sdk.getCurrentInstance().getObjectService("serviceName", { "access": "online" }); var dataObject = new kony.sdk.dto.DataObject("ObjectName"); //primary key details to get media object dataObject.addField("primary_key", "value"); objSvc.getBinaryContent({ "dataObject": dataObject, "binaryAttrName": "data" }, function(response) { kony.print("binary content is : " + JSON.stringify(response)); frmBinary.downloadImg.isVisible = true; frmBinary.downloadImg.base64 = response; }, function(error) { kony.print("failed to get binary data : " + JSON.stringify(error)); });
Creates binary content on the server.
createBinaryContent(options, successCallback, failureCallback);
Parameter | Description |
---|---|
options | JSON object with the mandatory parameter "dataObject", which is an instance of the kony.sdk.dto.DataObject Class, and "binaryAttrName", which is the binary field name in the object |
successCallback |
Function invoked when the operation succeeds, with the number of records created |
failureCallback | Function invoked when the operation fails, with cause of failure |
var objSvc = kony.sdk.getCurrentInstance().getObjectService("serviceName", { "access": "online" }); var dataObject = new kony.sdk.dto.DataObject("ObjectName"); dataObject.addField("name", "imgName"); dataObject.addField("data", "binaryText"); objSvc.createBinaryContent({ "dataObject": dataObject, "binaryAttrName": "data" }, function(response) { kony.print("Binary content created: " + JSON.stringify(response)); }, function(error) { kony.print("Failed: " + JSON.stringify(error)); });
Updates binary content on the server.
updateBinaryContent(options, successCallback, failureCallback);
Parameter | Description |
---|---|
options | JSON object with the mandatory parameter "dataObject", which is an instance of the kony.sdk.dto.DataObject Class, and "binaryAttrName", which is the binary field name in the object |
successCallback |
Function invoked when the operation succeeds, with the number of records updated |
failureCallback | Function invoked when the operation fails, with cause of failure |
var objSvc = kony.sdk.getCurrentInstance().getObjectService("serviceName", { "access": "online" }); var dataObject = new kony.sdk.dto.DataObject("ObjectName"); dataObject.addField("name", "imgName"); dataObject.addField("data", "binaryText"); objSvc.updateBinaryContent({ "dataObject": dataObject, "binaryAttrName": "data" }, function(response) { kony.print("Binary content updated: " + JSON.stringify(response)); }, function(error) { kony.print("Failed: " + JSON.stringify(error)); });
Copyright © 2020 Kony, Inc. All rights reserved. |