开发者

AX2009 EP Custom lookup with joined tables

I'm trying to make custom lookup (in .Net) using 2 joined tables:

AxLookup nameLookup = e.LookupControl;
Proxy.QueryBui开发者_Python百科ldDataSource 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";

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?

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.

Any help is appreciated!


This has been discussed in the following blog post: http://palleagermark.blogspot.com/2009/12/data-set-lookups-on-enterprise-portal.html

The answer is that you cannot use a datasource with a join with the AxLookup control as it was built to support only one DataSetView and will throw this exception if you have more than one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜