web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

X++ code using SysComputedColumn to use addList in D365FO

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

Hi,

In this post, we will view the code to use addlist method of SysComputedColumn in D365FO.

Step 1: Created a view DAXSalesInvoiceHeaders(namely) and added tables CustInvoiceJour and SalesTable as its datasources. Added fields InvoiceAccount, InvoiceAmount, InvoiceId, SumTax, InvoiceDate and DiscountAmount.

pastedimage1680238421532v1.png

Step 2: Created a method "computeTotalDiscountAmount" to display the total of the cash discount, Line discount and Total discount using addList method of SysComputedColumn.

 /// 
    /// SQL to compute the total discount amount for the sales invoice header.
    /// 
    private static str computeTotalDiscountAmount()
    {
        TableName   viewName      = tableStr(DAXSalesInvoiceHeaders); //Entity name
        List		fieldList = new List(types::String);

        fieldList.addEnd(SysComputedColumn::returnField(viewName, identifierstr(CustInvoiceJour), fieldstr(CustInvoiceJour, EndDisc)));
        fieldList.addEnd(SysComputedColumn::returnField(viewName, identifierstr(CustInvoiceJour), fieldstr(CustInvoiceJour, SumLineDisc)));
        fieldList.addEnd(SysComputedColumn::returnField(viewName, identifierstr(CustInvoiceJour), fieldstr(CustInvoiceJour, CashDisc)));

        return SysComputedColumn::addList(fieldList);
    }

Step 3:   Assigned view method "computeTotalDiscountAmount" to the field "DiscountAmount".

7711.pastedimage1680238133945v2.png

Step 4: Build the solution. In the table browser able to see the total discount amount for sales invoices.

Output:

pastedimage1680238306906v3.png

Regards,

Chaitanya Golla

Comments

*This post is locked for comments