Android SDK Samples - Subforms Operations

Update Subform's Data
          
          
//$record is the object of ZCRMRecord
$record.setFieldValue(s)

//define the subforms with their data
val subformList1 = arrayListOf<ZCRMSubformRecord>()
val subformList2 = arrayListOf<ZCRMSubformRecord>()

//call newSubFormRecord() by passing the subformName as  a parameter

//subformName - Name of the sub form to be created.

val subform1 = ZCRMSDKUtil.getModuleDelegate("Contacts").newSubFormRecord("Languages")
	   subform1.setFieldValue("Proficiency", "Native")
    subform1.setFieldValue("Languages_Known", "French")
    subformList1.add(subform1)

val subform2 = ZCRMSDKUtil.getModuleDelegate("Contacts").newSubFormRecord("Availability")
    subform2.setFieldValue("Location", "Zylker Inc")
    subform2.setFieldValue("Availability", "Weekdays")
    subformList2.add(subform2)

//call addSubforms() using $record object by passing the name of the subform and the subform lists as parameters
$record.addSubforms("Languages",subformList1)
$record.addSubforms("Availability", subformList2)

//call update() using $record object 
$record.update(object : DataCallback<APIResponse, ZCRMRecord>
{
   override fun completed(response: APIResponse, zcrmRecord: ZCRMRecord)
   {
       println("${response.responseJSON}")
   }

   override fun failed(exception: ZCRMException)
   {
       println("Throws Exception: $exception")
   }

})
 
Insert Subform's Data
          
          
//$record object is of ZCRMRecord
$record.setFieldValue("Last_Name", "Batman")

val subformList = arrayListOf<ZCRMSubformRecord>()
//define the subform records

//call newSubFormRecord() by passing the subformName as a parameter

//subformName - Name of the sub form to be created.

val subform1 = ZCRMSDKUtil.getModuleDelegate("Contacts").newSubFormRecord("Languages")
    subform1.setFieldValue("Proficiency", "Native")
    subform1.setFieldValue("Languages_Known", "French")

val subform2 = ZCRMSDKUtil.getModuleDelegate("Contacts").newSubFormRecord("Languages")
    subform2.setFieldValue("Proficiency", "Conversational")
    subform2.setFieldValue("Languages_Known","English")

val subform3 = ZCRMSDKUtil.getModuleDelegate("Contacts").newSubFormRecord("Languages")
    subform3.setFieldValue("Proficiency", "Beginner")
    subform3.setFieldValue("Languages_Known","Japanese")

//add subform records to the subformList
    subformList.add(subform1)
    subformList.add(subform2)
    subformList.add(subform3)

//call addSubforms() using $record object by passing the name of the subform and the subform lists as parameters
$record.addSubforms("Languages",subformList)

//call update() using $record object
$record.update(object : DataCallback<APIResponse, ZCRMRecord>
{
   override fun completed(response: APIResponse, record: ZCRMRecord)
   {
       println("${response.responseJSON}")
   }

   override fun failed(exception: ZCRMException)
   {
       println("Throws Exception: $exception")
   }

})