最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

将表添加到默认描述 / Add table to a default description

网络文摘 William 725浏览 0评论

Purpose:

The purpose of this post is to demonstrate how can we extend default descriptions by adding a new table to the default description definition.

Application:

Dynamics 365 Finance and Operations

Prerequisites:

  • Understanding of how default descriptions work

Business requirement:

Use customer free text invoice line description field in the definition of Customer – tax invoice, customer default description. Out of the box only two tables are available to select, CustInvoiceTable and CustInvoiceJour. The requirement is to add CustInvoiceLine.

Solution:

It can be achieved by developing an extension class of TransactionTextContextCust class.

Code

[ExtensionOf(classStr(TransactionTextContextCust))]
final class TransactionTextContextCustMAK_Extension
{
    private CustInvoiceLine custInvoiceLine;

    /// <summary>
    /// Provides a list of tables that are supported for use with a specified transaction type.
    /// </summary>
    /// <returns>
    /// A container that contains a collection of <c>TableId</c> values of tables that are supported by a
    /// specified transaction type.
    /// </returns>
    public container getSupportedTables()
    {
        container tableList;

        tableList = next getSupportedTables();

        tableList += tableNum(CustInvoiceLine);

        return tableList;
    }

    /// <summary>
    /// Sets the parameter variable of an object to contain the records that are used with a specified
    /// transaction type.
    /// </summary>
    /// <remarks>
    /// This method must be called before the table fields and values are mapped for the transaction text
    /// setup parameters.
    /// </remarks>
    public void setParameters()
    {
        next setParameters();

        parameters = [custInvoiceJour, custInvoiceTable, custInvoiceLine];
    }

    /// <summary>
    /// Set a particular table buffer for a specified transaction type.
    /// </summary>
    /// <param name="_common">
    /// The <c>Common</c> record that is set based on the <c>TableId</c> value of the buffer.
    /// </param>
    /// <returns>
    /// true if the table is supported and the buffer is saved; otherwise, false.
    /// </returns>
    /// <remarks>
    /// The <c>Common</c> record is cast to the appropriate table through switch logic.
    /// This method can be called repeatedly to assign multiple buffers.
    /// </remarks>
    /// <exception cref="M:Exception::Error">
    /// The table is not supported by this transaction type.
    /// </exception>
    public boolean setTableBuffer(Common _common)
    {
        boolean tableBufferSet;

        tableBufferSet = next setTableBuffer(_common);

        switch (_common.TableId)
        {
            case tableNum(CustInvoiceTable):
                custInvoiceLine = CustInvoiceLine::findByParentRecId(custInvoiceTable.RecId);
                tableBufferSet = true;
                break;
        }

        return tableBufferSet;
    }

}
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址