Skip to main content

Android SDK Samples - Subforms Operations

Update Subform's Data
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")
   }

})