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); }
If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.
Buy Me a CoffeeNo comments. Be the first one to comment on this post.
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 "buy me a coffee" link.
Join us.