Linking purchase orders with sales order using x++
When importing data from another system, especially a data migration, you might want to build links between purchase orders and sales order. This can be done by updating the following points of the system:
The table InterCompanyPurchSalesReference needs to contain a record that points the purchase order to the appropriate sales order. This table only has two fields, salesid and purchid.
The second step you need to complete is to populate three fields on the purchase line and sales line to complete the link. On the purchase line the fields are:
ItemRefType this is an enum and should have the value InventRefType::sales
InventRefId This is the salesid
InventRefTransId This is the inventtransid from the sales line that the purchase order line is linked against.
On the sales line the fields are:
InventRefType this is an enum and should have the value InventRefType::purch
InventRefId This is the purchid
InventRefTransId This is the inventtransid from the purchase line that the sales order line is linked against.
Once all the above have been setup you will find the links between the purchase order ans sales order are complete, and the marking between the inventory transaction are present.

This was originally posted here.
*This post is locked for comments