Skip to main content

iOS SDK Samples - Related Lists Operations

Get Related Records
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)" )
            }
        }