Android SDK Samples - Related Lists Operations
//$module object is of ZCRMModule
//call getRelatedLists() using $module object
$module.getRelatedLists(object :DataCallback<BulkAPIResponse,List<ZCRMModuleRelation>>
{
override fun completed(response: BulkAPIResponse,moduleRelations: List<ZCRMModuleRelation>) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception: $exception")
}
})
//$module object is of ZCRMModule
//call getRelatedListsFromServer() using $module object
$module.getRelatedListsFromServer(object :DataCallback<BulkAPIResponse,List<ZCRMModuleRelation>>
{
override fun completed(response: BulkAPIResponse,moduleRelations: List<ZCRMModuleRelation>) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception: $exception")
}
})
//$module object is of ZCRMModule
//call getRelatedList() using $module object by passing relatedlistId as a parameter
//relatedlistId - Id of the Related list to be returned
$module.getRelatedList(371xxx797, object:DataCallback<APIResponse,ZCRMModuleRelation>
{
override fun completed(response: APIResponse, moduleRelation: ZCRMModuleRelation) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception: $exception")
}
})
//$module object is of ZCRMModule
//call getRelatedListFromServer() using $module object by passing relatedlistId as a parameter
//relatedlistId - Id of the Related list to be returned
$module.getRelatedListFromServer(371xxx797, object:DataCallback<APIResponse,ZCRMModuleRelation>
{
override fun completed(response: APIResponse, moduleRelation: ZCRMModuleRelation) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception: $exception")
}
})
val parentRecord = ZCRMSDKUtil.getModuleDelegate("Contacts").getRecordDelegate(371xxx06) //id - ID of the record
val recordParams = ZCRMQuery.Companion.GetRecordParams()
recordParams.includePrivateFields
//$moduleRelation object is of ZCRMModuleRelation
//call getRelatedRecords() using the $moduleRelation object by passing the parentRecord and recordParams as parameters
//parentRecord - Record object of the ZCRMRecordDelegate.
//recordParams - Record parameters are given as an object.
$moduleRelation.getRelatedRecords(parentRecord,recordParams,object:DataCallback<BulkAPIResponse,List<ZCRMRecord>>
{
override fun completed(response: BulkAPIResponse, zcrmentity: List<ZCRMRecord>) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception: $exception")
}
})
val junctionRecords = arrayListOf<ZCRMJunctionRecord>()
val parentRecord = ZCRMSDKUtil.getModuleDelegate("Contacts").getRecordDelegate(371xxx006)//id - ID of the record
//$moduleRelation is the object of ZCRMModuleRelation
//call getJunctionRecordInstance() using $moduleRelation object by passing relatedRecordId as parameter
//relatedRecordId - Id of the related record
val relatedRec1 = $moduleRelation.getJunctionRecordInstance(371xxx005)
val relatedRec2 = $moduleRelation.getJunctionRecordInstance(371xxx016)
junctionRecords.add(relatedRec1)
junctionRecords.add(relatedRec2)
//call deleteRelations() by passing the junctionRecords list as a parameter
parentRecord.deleteRelations(junctionRecords,object:ResponseCallback<BulkAPIResponse>{
override fun completed(response: BulkAPIResponse) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception: $exception")
}
})