有时,我们需要根据交易参考ID的状态来过滤表单网格。假设我们要在到达概览表格中显示带有确认单据状态的采购订单。文档状态字段位于采购表中。为此,我尝试将WMSArrivalOverviewTmp外部连接到采购表并添加Range。但是结果并不像我预期的那样。这是我在初始化的数据源事件中尝试过的代码:
[FormDataSourceEventHandler(formDataSourceStr(WMSArrivalOverview, WMSArrivalOverviewTmp), FormDataSourceEventType::Initialized)]
public static void WMSArrivalOverviewTmp_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
QueryBuildDataSource qbds = sender.queryBuildDataSource();
QueryBuildDataSource qbdsPO;
qbdsPO = qbds.addDataSource(tableNum(PurchTable));
qbdsPO.clearRange(fieldNum(PurchTable, DocumentState));
qbdsPO.joinMode(JoinMode::OuterJoin);
qbdsPO.fetchMode(QueryFetchMode::One2One);
qbdsPO.addLink(fieldNum(WMSArrivalOverviewTmp, InventTransRefId ),fieldNum(PurchTable, PurchId), qbds.name());
qbdsPO.relations(false);
qbdsPO.addRange(fieldNum(PurchTable, DocumentState)).value(SysQuery::value(VersioningDocumentState::Confirmed));
info(sender.query().toString());
}
而且,我将事件类型更改为查询执行,但出现错误:
[[Microsoft] [用于SQL Server的ODBC驱动程序17] [SQL Server]错误转换数据类型为nvarchar到bigint。无法选择采购订单(采购表)中的记录。 SQL数据库已发出错误。
OnModified
事件上发生。尽管也许我误会了-如果这种情况在您开始提问时更像是“ 我们需要在表单加载时一直发生”而不是“
有时需要我们]]”-更改查询的地方是在数据源的OnQueryExecuting
事件的处理程序中对其进行修改。发生事件时,有两种修改事件查询的方法。
FormRun formRun = sender.formRun() as FormRun;
FormDataSource formDataSource = formRun.dataSource(formDataSourceStr(WMSArrivalOverview, WMSArrivalOverviewTmp));
//First way - get the base query and use executeQuery() to reload changes
Query query = formDataSource.query();
//modified query here.
formDataSource.executeQuery();
//Second way - get the current queryRun query and use research() to reload changes
Query query = formDataSource.queryRun.query();
//modified query here.
formDataSource.research();