Dynamics AX 2012-对话框中的自定义查找 [英] Dynamics AX 2012 - Custom Lookup in a dialog

查看:74
本文介绍了Dynamics AX 2012-对话框中的自定义查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在研究一个名为 DMFWriteExportData 的类,并试图使其在批处理中运行.我在某个时候需要找出一种摆脱fieldControl的方法,原因是它不允许我在服务器上运行该类并抛出错误,因为它不应该在服务器上运行?(不确定)

So, I am working on a class called DMFWriteExportData and trying to get it run in Batch. I am at a point where I need to figure out a way to get rid of fieldControl and the reason being it does not let me Run the class on the server and throws an error because it is not supposed to be running on server? (not sure)

Error: "The method Dialog Control.control cannot be called from the server; use methods on the Dialog Field class instead."

-

public Object dialog()
{   
    DialogRunbase       dialog = new DialogRunbase("@DMF372", this);
    FormStringControl   control;
    dialogExecution = dialog.addFieldValue(extendedTypeStr(dMFExecutionId), executionId);
    control         = dialogExecution.fieldControl();
    control.mandatory(true);
    control.displayLength(24);
    control.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(DMFWriteExecutionParameters, executionIdLookup), this);
    control.registerOverrideMethod(methodstr(FormStringControl, modified), methodstr(DMFWriteExecutionParameters, executionIdModified), this);
    dialogdescription=dialog.addFieldValue(extendedTypeStr(description),DMFExecution::find(executionId).Description);
    dialogdescription.enabled(false);

    return dialog;
}

我想知道:

  1. 如果确实如此,则不能将此类设置为服务器使用control.registerOverrideMethod
  2. 如果是,克服这种情况的理想解决方案是,有什么方法可以创建自定义查找?我看到有方法在DialogField类中称为registerOverrideMethod.

任何帮助将不胜感激.

谢谢,霍斯拉

推荐答案

之所以不能(并且应该)批量运行上面的代码,是因为它使用了仅在客户端存在的对话框控件.您永远不要在服务器上运行这种代码.请检查您类的 runon 属性并将其设置为from.

The reason why you cannot (and should) run the code above in batch is because it uses dialog controls that only exist on the client side. You should never run this kind of code on server. Please check runon property of your class and set it to called from.

但是,我假设您正在使用RunBaseBatch.如果您使用的是AX 2012,则应改用SysOperation框架.

However, I assume you are using RunBaseBatch. If you are on AX 2012, you should use the SysOperation framework instead.

使用RunBaseBatch时,所有代码都在同一类上.这样,您将客户端代码( main 方法, dialog 方法等)与应该在服务器上运行的代码( run 方法)混合在一起.因此,您应该将类​​的"runon"属性设置为 CalledFrom ,而不是 Server .您可以通过使用 SysOperation 解决此问题,该方法将模型视图控制器(MVC)模式巧妙地分隔开来.

When using RunBaseBatch, all code is on the same class. This way, you are mixing client side code (main method, dialog method etc) with the code that should run on server (run method). For this reason you should set the "runon" property of the class to CalledFrom, not Server. You can solve this by using SysOperation which applies the Model View Controller (MVC) pattern that neatly sepperates the two.

有关SysOperation的介绍,请在此处查看我的博客: AX2012:SysOperation简介

For an introduction to SysOperation, check my blog here: AX2012: SysOperation introduction

这篇关于Dynamics AX 2012-对话框中的自定义查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆