简体   繁体   English

在 Dynamics AX 4.0 中为 dialox 创建查找筛选器

[英]Create a lookup filter for a dialox in Dynamics AX 4.0

I'm trying to create a custom lookup filter in a dialog in AX.我正在尝试在 AX 的对话框中创建自定义查找过滤器。

I've followed the instructions in this post x++ filter lookup in dialog and am getting a Stack Trace error -- FormRun object not initialized -- when I'm run my code.我已按照这篇文章中的说明进行操作x++ 过滤器在对话框中查找,并且在运行我的代码时收到堆栈跟踪错误 -- FormRun object 未初始化 --。

What I am trying to do is filter the lookup() for the ConfigId EDT based on the selection from the ItemId EDT.我想要做的是根据从 ItemId EDT 中选择的内容过滤 ConfigId EDT 的 lookup()。 I have the custom lookup() ready to go and working properly, I just can't get it called from my dialog box.我已准备好自定义 lookup() 到 go 并正常工作,只是无法从我的对话框中调用它。

public Object dialog(DialogRunbase _dialog, boolean _forceOnClient)
{
    DialogRunBase   dialog;
    ;

    dialog = super(_dialog, true);

    dialog.caption('@RID2885');

    dfItem = dialog.addField(typeid(ItemId));
    dfInventLoc = dialog.addField(typeid(InventLocationId));
    dfReplaceCost = dialog.addField(typeid(PdsCost));
    dfItemConfig = dialog.addField(typeid(ConfigId));
    dfColorId = dialog.addField(typeid(InventColorId), '@RID101');

    return dialog;
}

Here's the call to the lookup():这是对 lookup() 的调用:

void Fld_7_lookup()
{
    Formrun fr = this.dialogModify().parmDialog();
    Object control = fr.controlCallingMethod();    
    ;

    ConfigTable::lookupConfigIdSimple(control, dfItem.value());    
}

And this is where it keeps getting the Stack Trace error:这就是它不断收到堆栈跟踪错误的地方:

public void dialogPostRun(DialogRunbase _dialog)
{
    ;
     super(_dialog);
    **_dialog.formRun().controlMethodOverload(true);** // Causes Stack Trace error
    _dialog.formRun().controlMethodOverloadObject(this);       
}

I have tried multiple configurations with the dialog box.我已尝试使用对话框进行多种配置。 When the code reaches that point, it still has information passed in from the dialog() method, but when it goes to get the FormRun, that object is blank.当代码到达那个点时,它仍然有从 dialog() 方法传入的信息,但是当它去获取 FormRun 时,object 是空白的。

Could someone please help me understand why there is no FormRun object associated with the DiaglogRunBase that is passed-in?有人可以帮我理解为什么没有与传入的 DiaglogRunBase 关联的 FormRun object 吗?

Thanks.谢谢。

Mayby you should call super(_dialog) last in the dialogPostRun method.也许你应该在dialogPostRun方法中最后调用super(_dialog)

Have a look on a similar solution and one more .看看类似的解决方案一个更多的解决方案。

Did you check to see if your class is set to run at "Called From"?您是否检查过您的 class 是否设置为以“Called From”运行?

Here is an example code for overriding the modified method.这是覆盖修改后的方法的示例代码。 Maybe lookup has the same requirements:也许查找具有相同的要求:

public void dialogPostRun(DialogRunbase _dialog)
{
// Must be overriden to enable overriding modified method
;
    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
    _dialog.formRun().controlMethodOverload(true);
    _dialog.formRun().controlMethodOverloadObject(this);

    super(_dialog);
}

And for the custom method:对于自定义方法:

boolean Fld2_1_modified()
{
    FormStringControl c = dialog.formrun().controlCallingMethod();
    boolean ret;
    ;

    ret = c.modified(); // Super() Call the FormControl ->modified

    dlgCustomField.value(MyClass::someMethod(dlgCustomField.value())); // example

    return ret;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM