Axapta 尝试从FormRun检索数据源时获取null

Axapta 尝试从FormRun检索数据源时获取null,axapta,x++,Axapta,X++,我有两张表格,我们称之为表格A和表格B。 在表格A中,我有一个按钮(空白按钮),当点击该按钮时,它将重定向到带有参数的表格B,该参数将被注入表格B的数据源。我检索表格B的数据源失败,它总是返回null [FormControlEventHandler(formControlStr(htVehicleListPage, FormCommandButtonControl1), FormControlEventType::Clicked)] public static void FormCom

我有两张表格,我们称之为表格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();
    }

FormRun
只是……它是正在运行的表单对象。您的
openningFormDataSource
将为null,因为您在
formRunObj.init()之前调用它并且表单尚未运行

它先是
Form.init()
,然后是
Form…Datasource.init()
,然后基本上是
Form.run()

formRunObj.init()
移到更高的位置,然后重试