SalesLine getSourceSalesLine(SalesLine _salesLine) { SalesLine sourceSalesLine; PurchLine sourcePurchLine; select firstonly crosscompany RecId from sourcePurchLine where sourcePurchLine.InterCompanyInventTransId == _salesLine.InventTransId join sourceSalesLine where sourceSalesLine.DataAreaId == sourcePurchLine.DataAreaId && sourceSalesLine.InventRefType == InventRefType::Purch && sourceSalesLine.InventRefTransId == sourcePurchLine.InventTransId; return sourceSalesLine; }Find the root order line if the intercompany chain consists of more orders (LE1 SO -> LE1 PO -> LE2 SO -> LE2 PO -> LE3 SO):
SalesLine salesLineUpdate = this; // this == SalesLine while (salesLineUpdate.InterCompanyInventTransId && salesLineUpdate.InterCompanyOrigin != InterCompanyOrigin::Source) { salesLineUpdate = getSourceSalesLine(salesLineUpdate); }
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 and "buy me a coffee" link.
Join us.