diff --git a/modules/plugin_dbui/dbsvc.py b/modules/plugin_dbui/dbsvc.py
index 194be021fcfee91458edbc9970ab0c4916e058ba..42d7a03615719ad7e599e53017a3e2cb81c01bbd 100644
--- a/modules/plugin_dbui/dbsvc.py
+++ b/modules/plugin_dbui/dbsvc.py
@@ -6,6 +6,7 @@ __version__ = "$Revision$"
 
 
 from basesvc import BaseSvc
+from foreignfield import ForeignField
 from cfgsvc import ROOT, SUCCESS, TOTAL
 from gluon.contrib import simplejson as json
 from helper import encode_field, decode_field, rows_serializer
@@ -58,6 +59,12 @@ class DbSvc(BaseSvc):
     The exception can be catch to generate an HTTP error.
 
     """
+    def __init__(self, environment):
+        
+        BaseSvc.__init__(self, environment)
+        db = self.environment['db']
+        self.model = ForeignField(db)
+
 
     def _check_request(self, arg, keywords=('tableName', 'records')):
         """Helper function to check that the request arg is well formed.
@@ -172,8 +179,8 @@ class DbSvc(BaseSvc):
 
     def _get_record(self, table, id):
         """Helper function to get the record id in a form which can be decoded
-        by the JsonReader. Foreign key are resolved.
-        Return a dictionary where key are the field encoded TableField.
+        by the JsonReader running on the client side. Foreign key are resolved.
+        Return a dictionary where key are encoded as TableField.
         
         """
         db = self.environment['db']
@@ -182,8 +189,15 @@ class DbSvc(BaseSvc):
         for field in db[table].fields:
             key = encode_field(table, field)
             record[key] = db[table][id][field] 
-            print table, id, field, record[key]
 
+            if self.model.is_foreign_field(table, field):
+                k_table, k_field, k_query = \
+                self.model.get_foreign_data(table, field)
+                
+                k_key = encode_field(k_table, k_field)
+                k_id = record[key]
+                record[k_key] = db[k_table][k_id][k_field]
+                
         return record