我有2种表格,我们将其称为表格A和B。 在表单A中,我有一个按钮(空白按钮),单击该按钮时它将重定向到带有参数的表单B,并且该参数将注入到表单B的数据源中。我无法检索到表单B的数据源,但始终返回null。
[FormControlEventHandler(formControlStr(htVehicleListPage, FormCommandButtonControl1), FormControlEventType::Clicked)]
public static void FormCommandButtonControl1_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormDataSource htVehicleTable= sender.formRun().dataSource(formDataSourceStr(htVehicleListPage,htVehicleTable));
htVehicleTable record=htVehicleTable.cursor();
info(int2Str(record.htVehicleID)); //result: some legit ID.
Args argsObj=new Args();
argsObj.name(formStr(htVehicleMaintenanceDetails));
FormRun formRunObj=new FormRun(argsObj);
FormDataSource openningFormDataSource =formRunObj.dataSource(formDataSourceStr(htVehicleMaintenanceDetails,htVehicleMaintenance)); //result: openningFormDataSource is null, however, formRunObj is not null.
Query queryObj=new Query();
openningFormDataSource.query(queryObj);
QueryBuildDataSource queryBuildDataSourceObj=queryObj.addDataSource(tableNum(htVehicleMaintenance));
queryBuildDataSourceObj.addRange(fieldNum(htVehicleMaintenance,htVehicleID)).value(strFmt("htVehicleMaintenance.htVehicleID=%1",record.htVehicleID));
formRunObj.init();
formRunObj.run(); //if we inorge the null error it will show a form here
formRunObj.wait();
}
答案 0 :(得分:5)
FormRun
只是...它是正在运行的表单对象。您的openningFormDataSource
将为空,仅仅是因为您在formRunObj.init();
之前调用了该表单,而表单尚未运行。
先行Form.init()
,然后再行Form...Datasource.init()
,然后再行Form.run()
。
将您的formRunObj.init()
移至更高位置,然后重试。