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

Community site session details

Session Id :

X++ code using count method of SysComputedColumn in D365FO

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

Hi,

In this post will provide the code to view the usage of count method of class SysComputedColumn in D365FO.

Step 1: Created a simple view (say)DAXCustomerTransCount with CustTable and CustTrans.

6253.pastedimage1670478536168v1.png

Step 2: Selected field AccountNum of datasource CustTable and field TransType of datasource CustTrans under GroupBy node respectively.

8228.pastedimage1670478636598v2.png

Step 3: Created a view method by name computedTransCountStr to show the count of transactions for every customer based on transaction type.

public class DAXCustomerTransCount extends common
{
    private static str computedTransCountStr()
    {
        TableName   viewName        = tableStr(DAXCustomerTransCount); //Entity name
        str         accountNumCount = SysComputedColumn::returnField(viewName, identifierStr(CustTrans), identifierStr(RecId));
        
        return SysComputedColumn::count(accountNumCount);
    }

}

Step 4: Created the following on the view:

  • Mapped field AccountNum from CustTable
  • Mapped field TansType from CustTrans.
  • Unmapped field TransCount(namely) and selected the method computedTransCountStr

pastedimage1670479375894v1.png

Step 5: Build the solution and using table browser of D365FO viewed the data returned by view DAXCustomerTransCount.

pastedimage1670479553423v1.png

Regards,

Chaitanya Golla

Comments

*This post is locked for comments