Lookup issue in AX and EDT relationships

Recently I came across an issue with populating the datagrid for a  combobox in AX.  (during migration of our project from 2009 to 2012). The lookup grid was empty though the view details opened up a form with two detail records.
So I added the following code by overriding the lookup method :
public void lookup()
{
    SysTableLookup          sysTableLookup;
    Query                   query;
    QueryBuildDataSource    queryBuildDataSource;
    ;

    sysTableLookup = SysTableLookup::newParameters(tablenum(tableName), this);
    query = new Query();
    queryBuildDataSource = query.addDataSource(tablenum(tableName));
    sysTableLookup.addLookupfield(fieldnum(tableName, NameOfColumnThatYouWantToSeeInTheLookup));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

The lookup then displayed the list of details , yet when I selected a particular value I got the following error: “Table ‘table name’ does not contain an index with id ’65535′ “
This was because of the relationship on the EDT because the value selected disobeyed it. EDT migration was the step missed out in the whole process, when I ran the EDT migration tool the problem was resolved- I was able to see the lookup without even writing code in the overridden method ‘lookup.’