iOS SDK Samples - Subforms Operations

Get a Subform's Data
          
          
// module is the object of getModuleDelegate()
$module.getRecord(id : 77xxx75) { ( result ) in
                            switch result
                            {
                            case .success(let obtainedRecord, let response) :
                                for eachrecord in obtainedRecord.subformRecord ?? [:]
                                {
                                    print(eachrecord)
                                }
                            case .failure(let error) :
                            print ( "Throws exception : \(error)" )
                            }
                        }
 
Update Subform's Data
          
          
// obtainedRecord is the object of getRecord()
      let subformRecord = obtainedRecord.subformRecord?[ key ]?.first
       subformRecord.setValue(ofFieldAPIName: "Home_Page", value: "www.google.com")
 		 subformRecord.setValue(ofFieldAPIName: "Social_Profiles", value: [ "Twitter" ])
        $obtainedRecord.update() { result in
      switch result
      {
       case .success(let record, let response) :
       print ("ResponseJSON : \( response.responseJSON )")
       case .failure(let error) :
       print("Error : \( error )")
         }
        }
 
Insert Subform's Data
          
          
let subform = ZCRMSDKUtil.getModuleDelegate(apiName: "Leads").newSubFormRecord (subFormName : " Languages " )
  subform.setValue(ofFieldAPIName: "Proficiency", value: "Native")
  subform.setValue(ofFieldAPIName: "Languages_Known", value: "French")
// record is the object of getRecord()
  $record.subformRecord?[ "Languages" ] = [ subform ]
  $record.update { ( result ) in
    switch result
     {
     case .success( let data, let response ) :
      print ("ResponseJSON : \( response.responseJSON )")
     case .failure( let error ) :
      print ( "Throws exception : \(error)" )
     }
    }