adsenseheader

Saturday, April 4, 2020

Get packing slip id for the Posted Invoice in Dynamics AX

Hi Guys,

If you are looking for code that needs to find a Packing slip Id for the posted Customer Invoice in Dynamics AX 365 for operations.

Below is the code that helps you out!


static void getPackingSlip(Args _args)
{
    CustInvoiceJour     custInvoiceJour;
    SalesParmTable      salesParmTable;
    CustPackingSlipJour custPackingSlipJour;
    SalesParmSubLine    salesParmSubLine;
    SalesParmLine       salesParmLine;

    custInvoiceJour = CustInvoiceJour::findRecId(35637193385);
    select firstOnly salesParmTable
        where salesParmTable.ParmId == custInvoiceJour.ParmId
            && salesParmTable.Ordering == DocumentStatus::Invoice;

    //in case of mulitple packing slip selected in invoice
    while select DocumentId from salesParmSubLine
            exists join salesParmLine
            where salesParmSubLine.LineRefRecId == salesParmLine.RecId
                && salesParmLine.ParmId          == salesParmTable.ParmId
                && salesParmLine.TableRefId      == salesParmTable.TableRefId
    {
        select firstOnly custPackingSlipJour
            where custPackingSlipJour.PackingSlipId == salesParmSubLine.DocumentId
                && custPackingSlipJour.SalesId == salesParmTable.SalesId;
        info(strFmt("%1-%2-%3-%4",custPackingSlipJour.DeliveryDate,custPackingSlipJour.PackingSlipId,salesParmTable.SalesId,custInvoiceJour.InvoiceId));
    }
}

No comments:

Post a Comment