
Hello all,
I have a question that will be better explained with an example.
Example:
Legal Entity A
Original Sales Order
Purchase Order
Legal Entity B
Intercompany Sales Order
Release the order partially creating multiple shipments for the same SO
The whole process of packing the items to a container and posting the packing slip is done on the Entity B for each shipment using a custom form. Every time a packing slip is posted for each shipment it auto generates a packing slip on the Original Sales Order which is a standard process.
Meaning that we will have multiple packing slips for the same SO.
The client wants to update a custom field on CustPackingSlipJour for both packing slips generated on the Entity A and the Entity B. (Not all of them so I can't use the SO).
So if I have two shipments with the same SO it will generate two packing slips for the Intercompany SO, and two for the Original sales Order.
I can easily find the correct packing slip to be updated FOR the intercompany sales order since the shipment and all the info is on Entity B. However, how can I find the related Packing slip generated on the Original Sales Order?
The only way I can see is using the Intercompany PO/SO to find it, but in this case I'll have multiple packing slips I need a way to find a 1 to 1 relation between both packing slips.
Any ideas?
This code below is what I'm using at the moment, but it doesn't help.
changecompany(salesTable.InterCompanyCompanyId)
{
SalesTable intercompanySalesTable = SalesTable::find(salesTable.InterCompanyOriginalSalesId);
if (intercompanySalesTable.SalesId)
{
ttsbegin;
while select forupdate custPackingSlipJour
where custPackingSlipJour.SalesId == intercompanySalesTable.SalesId
{
custPackingSlipJour.customField = _customField;
custPackingSlipJour.doUpdate();
}
ttscommit;
}
}Hi,
First of all, you're missing crosscompany syntax in your while select:
docs.microsoft.com/.../cross-company-x-code-basics
Second, I think if you filter by dataareaid, you should get the correct Packing Slip for your SO.