SalesLine getSourceSalesLine(SalesLine _salesLine) { SalesLine sourceSalesLine; PurchLine sourcePurchLine; select firstonly crosscompany RecId from sourcePurchLine where sourcePurchLine.InventTransId == _salesLine.InterCompanyInventTransId join sourceSalesLine where sourceSalesLine.DataAreaId == sourcePurchLine.DataAreaId && sourceSalesLine.InventRefType == InventRefType::Purch && sourceSalesLine.InventRefTransId == sourcePurchLine.InventTransId; return sourceSalesLine; }
SalesLine salesLineUpdate = this; // this == SalesLine while (salesLineUpdate.InterCompanyInventTransId && salesLineUpdate.InterCompanyOrigin != InterCompanyOrigin::Source) { salesLineUpdate = getSourceSalesLine(salesLineUpdate); }Using parent sales line (LE1 SO) find the child sales line (LE2 SO)
SalesLine childSalesLine; PurchLine childPurchLine; if (this.InventRefTransId) { /* select firstonly crosscompany childPurchLine where childPurchLine.DataAreaId == this.DataAreaId && childPurchLine.ItemRefType == InventRefType::Sales && childPurchLine.InventTransId == this.InventRefTransId join forupdate childSalesLine where childSalesLine.InventTransId == childPurchLine.InterCompanyInventTransId; // join select does not work as records are from different companies and on SQL level D365FO core sets T2.DATAAREAID = T1.DATAAREAID between joined datasources */ select firstonly childPurchLine where childPurchLine.DataAreaId == this.DataAreaId && childPurchLine.ItemRefType == InventRefType::Sales && childPurchLine.InventTransId == this.InventRefTransId; select firstonly crosscompany childSalesLine where childSalesLine.InventTransId == childPurchLine.InterCompanyInventTransId && childSalesLine.InterCompanyInventTransId == childPurchLine.InventTransId; }
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 365 FO.
Authors are allowed to set their own "buy me a coffee" link.
Join us.