Thursday, August 10, 2023

Select Min and Max dates from lines

/// <summary>
    ///  set date for inventtransfer header
    /// </summary>
    /// <param name = "_inventTransferTable">
    /// InventTransferTable buffer
    /// </param>
    /// <param name = "_purchId">
    /// Purchase order number
    /// </param>
    public void setDatesInventTransferTable(InventTransferTable _inventTransferTable, PurchIdBase _purchId)
    {
        InventTransferLine transferLine;

        _inventTransferTable.reread();
        _inventTransferTable.selectForUpdate(true);

        select minof(ShipDate), maxof(ReceiveDate) from transferLine
                                where transferLine.TransferId == _inventTransferTable.TransferId;

        _inventTransferTable.ShipDate = transferLine.ShipDate;
        _inventTransferTable.ReceiveDate =  transferLine.ReceiveDate;
        _inventTransferTable.PurchaseOrderId_DIS =  _purchId;

        _inventTransferTable.update();
    }

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8