Monday, May 22, 2023

How to add fields in standard Data entity in D365 using X++

 Here my requirement is to add fields in header and line data entities. 

            ·       Warehouse work header

·       Warehouse work Lines

Add fields in entity level , vertual fields.

Add fields with same names in staging tables


Header dataentity postload method:

[ExtensionOf(tableStr(WHSWarehouseWorkHeaderEntity))]

internal final class DaxWHSWarehouseWorkHeaderEntity_Extension

{

      public void postload()

    {

        WHSWorkTable    whsWorkTable;

        WHSWorkLine     whsWorkLine;

        WHSWarehouseWorkHeaderEntity    wHSWarehouseWorkHeaderEntity = this;

        Amount qty,qtyloc;

        while  select whsWorkLine

             where whsWorkLine.WorkId == wHSWarehouseWorkHeaderEntity.WarehouseWorkId

        {

            qty += whsWorkLine.QtyWork;

            qtyloc += whsWorkLine.QtyRemain;

        }

        wHSWarehouseWorkHeaderEntity.QtyWork = qty;

        wHSWarehouseWorkHeaderEntity.QtyRemain = qtyloc;

        next postload();

    }

  }


Line Dataentity postload method :

[ExtensionOf(tableStr(WHSWarehouseWorkLineEntity))]

internal final class DaxWHSWarehouseWorkLineEntity_Extension

{

    public void postload()

    {

        Inventbatch     inventBatch;

        WHSWarehouseWorkLineEntity whsWarehouseWorkLineEntity = this;

          select inventBatch

            where inventBatch.itemId == whsWarehouseWorkLineEntity.WarehouseWorkId

            && inventBatch.inventBatchId == whsWarehouseWorkLineEntity.ItemBatchNumber;

        whsWarehouseWorkLineEntity.ExpDate = inventBatch.expDate;

        whsWarehouseWorkLineEntity.ItemName = InventTable::find(whsWarehouseWorkLineEntity.ItemNumber).itemName();

        next postload();

            }

  }




No comments:

Post a Comment