Find original sales line by return sales line

// By return salesLine
returnSalesLine.InventTransIdReturn = originalSalesLine.InventTransId

// By return SalesId
protected SalesId getOriginalSalesId(SalesId _returnSalesId)
{
    SalesId             ret;
    SalesLine           salesLine;
    InventTransOrigin   inventTransOrigin;

    select firstOnly RecId from salesLine
        where salesLine.SalesId             == _returnSalesId
            &&salesLine.InventTransIdReturn != ''
        join RecId, ReferenceId from inventTransOrigin
            where inventTransOrigin.InventTransId       == salesLine.InventTransIdReturn
                &&inventTransOrigin.ReferenceCategory   == InventTransType::Sales;

    if (inventTransOrigin)
    {
        ret = inventTransOrigin.ReferenceId;
    }

    return ret;
}

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags