从 X++ 中的主 class 调用编辑方法

Call edit method from a main class in X++

我想调用 class 主窗体中声明的 edit 方法的值。我该怎么做?

[Form]
public class AdvancedCustomerSchedule extends FormRun
{        
    Sorting sorting;    

    edit Sorting edtSorting(boolean set, Sorting _sorting)
    {
        if (set)
        {
            sorting = _sorting;
        }
        return sorting;
    }
 }

和 class:

class AdvancedCustomerScheduleService 
{
  static void main(Args args)
  {
       //I want to call the method edtSorting here.
  }
}

更新

FormRun callerForm;
if (args.caller() is FormRun)
        {
            callerForm = args.caller() as FormRun;

            if (formHasMethod(callerForm, identifierStr(edtSorting)))
            {
                str test  = callerForm.edtSorting();
                info(test);
            }
        }

对于一般在表单上定义的调用方法,您通常使用如下模式:

...
FormRun callerForm;
...
if (_args.caller() is FormRun)
{
    callerForm = _args.caller();

    if (formHasMethod(callerForm, identifierStr(someMethod)))
    {
        callerForm.someMethod();
    }
    ...

查看 class DirPartyContactInfoFormHandler 及其静态 main 方法作为示例。