The ObjectService class provides methods that act on the Kony Fabric endpoint, including basic CRUD and metadata functions .
The following methods are used by the ObjectService class.
Creates an object in the Kony Fabric endpoint.
Create(dataObject, headers, queryParams);
Parameter | Type | Description |
---|---|---|
dataObject | DataObject |
An instance of the DataObject class which contains data about the object and its data. |
headers | Dictionary <string, string> |
Key/value pairs of httpHeaders that are sent along with the network call. |
queryParams | Dictionary <string, string> | Key/value pairs of query params that are appended to the url while making a network call. |
public void CreateObject() { Kony.SDK sdkObject = new Kony.SDK(); try { sdkObject.Init("<app_key>", "<app_secret>", "<service_url>"); Kony.ObjectService objectsvc = sdkObject.GetObjectService("<service_name>"); Kony.DataObject dataObject = new Kony.DataObject("<object_name>"); dataObject.AddField("field1", "value1"); JObject result = objectsvc.Create(dataObject); } catch (Exception e) { sdkObject.Log("Create Object Failed"); } }
Deletes an object in the Kony Fabric endpoint.
DeleteRecord(dataobject, headers, queryParams);
Parameter | Type | Description |
---|---|---|
dataObject | DataObject |
An instance of the DataObject class which contains data about the object and its data. |
headers (Optional) | Dictionary <string, string> |
Key/value pairs of httpHeaders that are sent along with the network call. |
queryParams (Optional) | Dictionary <string, string> | Key/value pairs of query params that are appended to the url while making a network call. |
public void DeleteObject() { Kony.SDK sdkObject = new Kony.SDK(); try { sdkObject.Init("<app_key>", "<app_secret>", "<service_url>"); Kony.ObjectService objectsvc = sdkObject.ObjectServices("<service_name>"); Kony.DataObject dataObject = new Kony.DataObject("<object_name>"); //Primary Key is Required to perform the DeleteRecord operation. dataObject.DeleteRecord("Primary_Key", "value"); JObject result = objectsvc.DeleteRecord(dataObject); } catch (Exception e) { sdkObject.Log("Delete Object Failed"); } }
Gets the metadata associated with the objects defined in the service from the server or local store.
GetMetadataOfAllObjects(headers, queryParams);
Parameter | Type | Description |
---|---|---|
headers | Dictionary <string, string> |
Key/value pairs of httpHeaders that are sent along with the network call. |
queryParams | Dictionary <string, string> | Key/value pairs of query params that are appended to the url while making a network call. To query data, the Odata Url is sent in this parameter. |
public void GetMetadataForAllObjects() { Kony.SDK sdkObject = new Kony.SDK(); try { sdkObject.Init("<app_key>", "<app_secret>", "<service_url>"); Kony.ObjectService objectsvc = sdkObject.ObjectServices("<service_name>"); Kony.Metadata objectsMetadata = null; objectsMetadata = objectsvc.GetMetadataOfAllObjects(); } catch (Exception e) { sdkObject.Log("Get Metadata Of All Objects Failed"); } }
Gets the metadata associated with an object defined in the service from the server or local store.
GetMetadataOfObject(objectName, headers, queryParams);
Parameter | Type | Description |
---|---|---|
objectName | string | Object name in Kony Fabric |
headers | Dictionary <string, string> |
Key/value pairs of httpHeaders that are sent along with the network call. |
queryParams | Dictionary <string, string> | Key/value pairs of query params that are appended to the url while making a network call. |
public void GetMetadataForObject() { Kony.SDK sdkObject = new Kony.SDK(); try { sdkObject.Init("<app_key>", "<app_secret>", "<service_url>"); Kony.ObjectService objectsvc = sdkObject.ObjectServices("<service_name>"); Kony.Metadata objectsMetadata = null; objectsMetadata = objectsvc.GetMetadataOfObject("<object_Name>"); } catch (Exception e) { sdkObject.Log("Get Metadata Of Object Failed"); } }
Partially updates an object in the Kony Fabric endpoint.
PartialUpdate(dataObject);
Parameter | Type | Description |
---|---|---|
dataObject | DataObject |
An instance of the DataObject class which contains data about the object and its data. |
headers | Dictionary <string, string> |
Key/value pairs of httpHeaders that are sent along with the network call. |
queryParams | Dictionary <string, string> | Key/value pairs of query params that are appended to the url while making a network call. |
public void PartialUpdateSampleObject() { Kony.SDK sdkObject = new Kony.SDK(); try { sdkObject.Init("<app_key>", "<app_secret>", "<service_url>"); Kony.ObjectService objectsvc = sdkObject.ObjectServices.<service_name>; Kony.DataObject dataObject = new Kony.DataObject("<object_name>"); dataObject.AddField("Updatedfield1", "Updatedvalue1"); //Primary Key is required to perform the update operation. dataObject.AddField("Primary_Key", "value"); JObject result = objectsvc.PartialUpdate(dataObject); } catch (Exception e) { sdkObject.Log("Update Object Failed"); } }
Updates an object in the Kony Fabric endpoint.
Update(dataobject, headers, queryParams);
Parameter | Type | Description |
---|---|---|
dataObject | DataObject |
An instance of the DataObject class which contains data about the object and its data. |
headers | Dictionary <string, string> |
Key/value pairs of httpHeaders that are sent along with the network call. |
queryParams | Dictionary <string, string> | Key/value pairs of query params that are appended to the url while making a network call. |
public void UpdateSampleObject() { Kony.SDK sdkObject = new Kony.SDK(); try { sdkObject.Init("<app_key>", "<app_secret>", "<service_url>"); Kony.ObjectService objectsvc = sdkObject.ObjectServices("<service_name>"); Kony.DataObject dataObject = new Kony.DataObject("<object_name>"); dataObject.AddField("Updatedfield1", "Updatedvalue1"); //Primary Key is required to perform the update operation. dataObject.AddField("Primary_Key", "value"); JObject result = objectsvc.Update(dataObject); } catch (Exception e) { sdkObject.Log("Update Object Failed"); } }
Copyright © 2020 Kony, Inc. All rights reserved. |