代码之家  ›  专栏  ›  技术社区  ›  Red Wei

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

  •  2
  • Red Wei  · 技术社区  · 7 年前

    我有两张表,我们叫A表和B表。 在表单A中,我有一个按钮(空白按钮),当单击该按钮时,它将重定向到带有参数的表单B,并且该参数将被注入到表单B的数据源中。我检索不到表单B的数据源,它总是返回空值。

    [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();
        }
    
    1 回复  |  直到 7 年前
        1
  •  5
  •   Alex Kwitny    7 年前

    FormRun 只是…它是running form对象。你的 openningFormDataSource 将为空,因为您以前调用过它 formRunObj.init();

    它走了 Form.init() ,然后它会 Form...Datasource.init() ,然后 Form.run() 基本上。

    移动你的 formRunObj.init() 再高一点再试一次。