iOS SDK Samples - Related Lists Operations

Get Related Records
          
          
// moduleRelation is th object of getRelatedLists()
// record is the object of getRecordDelegate
// recordParams is the object of GetRecordParams()

$moduleRelation.getRelatedRecords(ofParentRecord: record, recordParams: recordParams, completion: { ( relatedListResult ) in
     switch relatedListResult
      {
      case .success(let list, let response) :
        print ("ResponseJSON : \( response.responseJSON )")
      case .failure(let error) :
         print ( "Throws exception : \(error)" )
       }
		})
 
Update Related Records
          
          
// record is a object of getRecordDelegate
        var junctionRecords : [ ZCRMJunctionRecord ] = []
        for recordDetails in try addRelationDetails.getArrayOfDictionaries(key: "junctionRecordDetails")
        {
            let junctionRecord : ZCRMJunctionRecord = tryZCRMJunctionRecord( apiName : recordDetails.getString(key: "moduleName"), id : recordDetails.getInt64(key: "id") )
            for ( key, value ) intry recordDetails.getDictionary(key: "fieldDetails")
            {
                junctionRecord.setValue(ofField: key, value: value)
            }
            junctionRecords.append( junctionRecord )
        }
        $record.addRelations(junctionRecords: junctionRecords) { ( result ) in
            switch result
            {
            case .success(let response ) :
                 print ("ResponseJSON : \( response.responseJSON )")
            case .failure(let error) :
                 print ( "Throws exception : \(error)" )
            }
        }
 
          
          
// record is a object of getRecordDelegate
        var junctionRecords : [ ZCRMJunctionRecord ] = []
        for recordDetails in try addRelationDetails.getArrayOfDictionaries(key: "junctionRecordDetails")
        {
            let junctionRecord : ZCRMJunctionRecord = tryZCRMJunctionRecord( apiName : recordDetails.getString(key: "moduleName"), id : recordDetails.getInt64(key: "id") )
            for ( key, value ) intry recordDetails.getDictionary(key: "fieldDetails")
            {
                junctionRecord.setValue(ofField: key, value: value)
            }
            junctionRecords.append( junctionRecord )
        }  
        $record.deleteRelations(junctionRecords: junctionRecords) { ( result ) in
            switch result
            {
            case .success(let response ) :
              print ("ResponseJSON : \( response.responseJSON )")
            case .failure(let error) :
              print ( "Throws exception : \(error)" )
            }
        }