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;
}
}