Dynamics Ax 2012 对话 - 提问训练 material

Dynamics Ax 2012 Dialog - Questioning Training material

在培训中 material 我正在检查它是如何设置 3 个 DialogFields(我还展示了 table 声明:

CustTable custTable;

dlgCust = dlg.addField(extendedTypeStr(CustVendAc),"Customer account");
dlgGrp  = dlg.addField(extendedTypeStr(CustGroupId));
dlgCur  = dlg.addField(extendedTypeStr(CurrencyCode));

然后它尝试将对话框中的值保存到 custTable

custTable.AccountNum = dlgCust.value();
custTable.CustGroup = dlgGrp.value();
custTable.Currency = dlgCur.value();

为什么将 DialogFields 设置为一种扩展类型只是为了将其移动到另一种类型? CustVendAc、CustGroupId 和 CurrencyCode 在 CustTable 中都不存在。这样做有什么意义?

附带问题是:

我正在为此工作的实验室问我:

Create a new class that will prompt the user for a new customer account number, the name and all fields that are mandatory for the customer records. Use existing methods to validate the record before inserting the record into the database. In the case that not all data was entered, throw an error exception that has the error message: "Please enter all required fields." The code to create the record must be inside a try/catch statement. This must include a catch for the error exception type and display the message: "An error occurred. Please try again.".

它说要获取客户记录的帐号,名称和所有必填字段。我该如何自己确定呢?我查看了 table 和新的客户表单,它要求提供比他们的解决方案提供的信息更多的信息.​​..那么您如何确定要询问哪些字段?

dlgCust 不是 ExtendedDataType,它是 class 对象。 DialogField.

CustTable.AccountNum 是一个 Table.Field 您将值存储在对象中。

CustTable 中的

CustTable.AccountNum 字段属于 CustAccount 类型,它扩展了 CustVendAc EDT。所以基本上,它们都属于同一类型。

CustTable.CustGroupCustGroupId类型的,所以没问题。

CustTable.Currency 属于 CustCurrencyCode 类型,它扩展了 CurrencyCode.

Use existing methods to validate the record before inserting the record into the database.

使用custTable.validateWrite方法验证是否可以创建记录。如果缺少某些强制性记录,它将 return false 并且还会显示带有错误消息的信息日志。

It says to get the account number, the name, and all the fields that are mandatory for the customer record. How am I suppose to determine this on my own?

table 中的每个字段都有 Mandatory 属性。

代码将如下所示:

try
{
    custTable.initValue();

    custTable.AccountNum = dlgCust.value();
    custTable.CustGroup = dlgGrp.value();
    custTable.Currency = dlgCur.value();

    //Other mendatory fields like customer name

    if (custTable.validateWrite())
    {
       ttsBegin;
       custTable.insert();
       ttsCommit;
    }
    else
    {
       throw error("Please enter all required fields");
    }
}
catch
{
    error("An error occurred. Please try again");
}