How to create and use display methods in grid D365

 First Create a class e.g Class_Extension

- Public static class PurchTable_Extension

- Class and methods should be static 

- Add display keyword before method signature

- Add your logic and queries in the function

- datasource _this gives you the current data of the line. 

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


Usage:

- In grid, add a field, open properties, and select data source e.g; purchTable, and then select

  data method like this:  PurchTable_Extension::PurchCharges

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


Class:

public static class PurchTable_Extension

{

   [SysClientCacheDataMethodAttribute(true)]  //This attribute will cache your display method.

   public static display AmountCur PurchCharges(PurchTable _this)

   {


PurchTotals purchTotals;  //Calculate totals per Purchase order

PurchTable  purchTable  = PurchTable::find(_this.PurchId); //Change the Purchase Order Id as per your system's data

AmountCur   totalAmount;

purchTotals = PurchTotals::newPurchTable(purchTable);

 purchTotals.calc();

 totalAmount = purchTotals.purchOtherMiscCharges();

 return totalAmount;

}


Comments