How to create a lookup with fields from more than one datasource?

谁说胖子不能爱 提交于 2019-12-04 11:56:08

As far as I know the SysTableLookup class does not support showing fields from other tables. The addLookup() method doesn't take a TableId and assumes all fields are in the first datasource of the query.

You could write your own version of SysTableLookup that supports referencing fields from various tables. A simpler and more practical (and less expensive) approach might be to create a display method on SmmBusRelTable to fetch the name from DirPartyTable (if it doesn't already exists) and use that as a field in the lookup. Display methods on the main table are supported if I remember correctly.

Depending on what exactly you're trying to accomplish there might be an even simpler way. You could add the display method to the AutoLookup table field group of SmmBusRelTable and avoid having to override the lookup() method.

Brad Higginson

It is actually very easy to combine multiple datasources in a sysTableLookup. Here is the trick I used to be able to filter on the name from the EcoResProductTranslation in the lookup for items.

1) Create a view that combines all your datasources and add the fields you would like to see in your lookup to the view.
2) Create a query from the view created in step 1.
3) Use these to perform your lookup as follows...

static client void lookupItemActive(FormStringControl _ctrl)
{
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(<ViewName>),_ctrl);
    Query          query = new Query(queryStr(<QueryName>));

    sysTableLookup.addLookupfield(fieldnum(<ViewName>, ItemId));
    sysTableLookup.addLookupfield(fieldNum(<ViewName>, Name));
    sysTableLookup.addLookupfield(fieldNum(<ViewName>, ItemGroupId));
    sysTableLookup.addLookupfield(fieldnum(<ViewName>, Status));
    sysTableLookup.addLookupfield(fieldnum(<ViewName>, RevId));
    sysTableLookup.addLookupfield(fieldnum(<ViewName>, ItemType));

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!