title: AX2009 EP Custom lookup with joined tables
body: <p>I'm trying to make custom lookup (in .Net) using 2 joined tables:</p>
  
  <pre><code>AxLookup nameLookup = e.LookupControl;
  Proxy.QueryBuildDataSource emplTable = null;
  Proxy.QueryBuildDataSource dirPartyTable = null;
  
  using (Proxy.SysDataSetBuilder sysDataSetBuilder = proxy.SysDataSetBuilder.constructLookupDataSet(this.AxSession.AxaptaAdapter, TableMetadata.TableNum(this.AxSession, "EmplTable")))
  {
      nameLookup.LookupDataSet = new DataSet(this.AxSession, sysDataSetBuilder.toDataSet());        
  }
  
  using (Proxy.Query query = nameLookup.LookupDataSet.DataSetViews[0].MasterDataSource.query())
  {
      emplTable = query.dataSourceNo(1);
      dirPartyTable = emplTable.addDataSource(TableMetadata.TableNum(this.AxSession, "DirPartyTable"));
      dirPartyTable.clearLinks();
      dirPartyTable.addLink(TableDataFieldMetadata.FieldNum(this.AxSession, "EmplTable", "PartyId"), TableDataFieldMetadata.FieldNum(this.AxSession, "DirPartyTable", "PartyId"));                
      dirPartyTable.joinMode = 6;  //should be an exists join
  }
  
  nameLookup.LookupDataSet.Init();
  
  
  nameLookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, nameLookup.LookupDataSetViewMetadata.ViewFields["EmplId"]));
  nameLookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, nameLookup.LookupDataSetViewMetadata.ViewFields["DirPartyTable!Name"])); //not working!!
  
  nameLookup.SelectField = "EmplId";
  </code></pre>
  
  <p>Now when I use the lookup it gives me an errror about the Name field in DirPartyTable (key not found) Does someone know how to add a lookupfield in a joined table?</p>
  
  <p>I'm sure the join works ok, made some other lookups with ranges on the joined table (and ofcourse no lookupfields on the second table) and that works ok. </p>
  
  <p>Any help is appreciated!</p>