Skip to main content
Solved

Issue with CustomerOrderNbr Not Always Being Copied from Sales Order to Shipment

  • September 10, 2024
  • 3 replies
  • 55 views

chris49
Varsity II
Forum|alt.badge.img

Hello,

We’ve recently upgraded from Acumatica 2023 R1 to 2024 R1 and are encountering an issue involving the Sales Order and Shipment modules. Specifically, we’ve noticed that the CustomerOrderNbr field, which is typically copied from a Sales Order to a Shipment during shipment creation, is not consistently transferred.

This behaviour is managed by Acumatica’s core code and previously worked as expected on 2023 R1:

public virtual bool SetShipmentFieldsFromOrder(SOOrder order, SOShipment shipment, int? siteID, DateTime? shipDate, string operation, SOOrderTypeOperation orderOperation, bool newlyCreated)
{
    if (newlyCreated)
    {
        // Removed all of the other fields, only keeping below line for brevity
        [...]
        shipment.CustomerOrderNbr = order.CustomerOrderNbr;
        [...]

        if(string.IsNullOrEmpty(shipment.ShipmentDesc))
            shipment.ShipmentDesc = order.OrderDesc;

        return true;
    }
    else
    {
        // In our case, it's all newly created shipments, so this portion of the code can be ignored.
        [...]
    }
}

Problem:

When a shipment is created from a Sales Order, the CustomerOrderNbr is not always being copied to the shipment record. This issue occurs sporadically, without any error messages or clear patterns to reproduce the problem. We have multiple companies set up in our Acumatica instance, and the issue varies by company:

  • For 2 out of 3 companies, the issue happens occasionally.
  • For the 3rd company, the issue happens most of the time.

Just to point out, as can be seen in the code snippet above, the OrderDesc is copied over to the ShipmentDesc, and I can confirm, in the cases where the CustomerOrderNbr is null, the ShipmentDesc is indeed populated. So we know the code must’ve run through this if statement. 

Environment:

  • Version: Acumatica 2024 R1
  • Modules affected: Sales Order & Shipment

Additional context:

We do have customisation around the core functionality, but we are not making changes to the CustomerOrderNbr field itself, so we can’t see how our customisations would affect this specific behaviour, especially since the OrderDesc is indeed copied over to the ShipmentDesc.

#region SetShipmentFieldsFromOrder
public delegate Boolean SetShipmentFieldsFromOrderDelegate(SOOrder order, SOShipment shipment, Nullable<Int32> siteID, Nullable<DateTime> shipDate, String operation, SOOrderTypeOperation orderOperation, Boolean newlyCreated);
[PXOverride]
public Boolean SetShipmentFieldsFromOrder(SOOrder order, SOShipment shipment, Nullable<Int32> siteID, Nullable<DateTime> shipDate, String operation, SOOrderTypeOperation orderOperation, Boolean newlyCreated, SetShipmentFieldsFromOrderDelegate baseMethod)
{
    if (newlyCreated)
    {
        if (order != null)
        {
            SOOrderExt orderExt = order.GetExtension<SOOrderExt>();
            if (orderExt != null)
            {
                if (shipment != null)
                {
                    SOShipmentExt shipmentExt = shipment.GetExtension<SOShipmentExt>();
                    if (shipmentExt != null)
                    {
                        shipmentExt.UsrDeliveryInstructions = orderExt.UsrDeliveryInstructions;
                        shipmentExt.UsrOrderInstructions = orderExt.UsrOrderInstructions;
                        shipmentExt.UsrPargoPickupPoint = orderExt.UsrPargoPickupPoint;
                        shipmentExt.UsrPriority = CalculatePriority(order, shipment);

                        if (!string.IsNullOrEmpty(orderExt.UsrDispatchByDateTime.ToString()))
                        {
                            bool isPrimaryWarehouse = IsPrimaryWarehouse(order, siteID);
                            if (isPrimaryWarehouse)
                            {
                                shipmentExt.UsrDispatchByDateTime = orderExt.UsrDispatchByDateTime;
                                shipmentExt.UsrDispatchNoEarlierThanDateTime = orderExt.UsrDispatchNoEarlierThanDateTime;
                                shipmentExt.UsrEarliestDateTime = orderExt.UsrEarliestDateTime;
                                shipmentExt.UsrTargetDateTime = orderExt.UsrTargetDateTime;
                                shipmentExt.UsrPromiseDateTime = orderExt.UsrPromiseDateTime;
                            }
                            else
                            {
                                shipmentExt.UsrDispatchByDateTime = orderExt.UsrRerouteDispatchByDateTime;
                                shipmentExt.UsrDispatchNoEarlierThanDateTime = orderExt.UsrRerouteDispatchNoEarlierThanDateTime;
                                shipmentExt.UsrEarliestDateTime = orderExt.UsrRerouteEarliestDateTime;
                                shipmentExt.UsrTargetDateTime = orderExt.UsrRerouteTargetDateTime;
                                shipmentExt.UsrPromiseDateTime = orderExt.UsrReroutePromiseDateTime;
                            }
                        }
                    }
                }
            }
        }
    }

    return baseMethod(order, shipment, siteID, shipDate, operation, orderOperation, newlyCreated);
}
#endregion

 

The only scenario where I would expect this field not to be copied is when a shipment includes multiple orders, where Acumatica's core logic sets the field to null. However, in our case, each shipment has only one order assigned to it.

 

To add to the confusion, another strange occurrence is that we’ve observed cases where the CustomerOrderNbr was initially copied over as expected, but when inspecting it later, the value has gone to null.

 

This screenshot was taken on the 6th of September​​​​​​
This screenshot was taken on the 10th of September

 

What we’ve observed:

  • The issue did not occur before upgrading to Acumatica 2024 R1 (although we did jump a major version, we skipped 2023R2).
  • No error messages or logs seem to provide any clues as to why this field is not always copied.

Has anyone else encountered a similar issue after upgrading to 2024 R1? Are there any known changes in the core code that could have impacted this functionality? Any suggestions or insights would be greatly appreciated.

Thank you in advance!

Best answer by chameera71

It seems like you're encountering an issue with the CustomerOrderNbr field not being consistently copied to the shipment record after upgrading to Acumatica 2024 R1. While the behavior is sporadic, it's likely caused by underlying changes in Acumatica's core logic in this version. I'll walk you through some potential causes and approaches to debug and resolve the issue:

Key Observations:

  1. Issue Variability by Company: Since the issue occurs more frequently in one company and sporadically in others, it could be related to data-specific conditions or differences in setup between companies.

  2. Newly Created Shipments: Since this behavior is part of the newly created shipments, and the code reaches the point where OrderDesc is copied to ShipmentDesc, it's likely that the logic affecting CustomerOrderNbr might be conditionally skipped or overwritten after the initial copy.

  3. Core Code Changes in 2024 R1: The issue did not occur before upgrading, suggesting that there may be changes in the core Sales Order/Shipment logic in 2024 R1 that affect how the CustomerOrderNbr field is managed.

Possible Causes:

  1. Core Acumatica Logic Changes: Acumatica 2024 R1 may have modified the core logic that handles the copying of CustomerOrderNbr. Specifically, there could be conditions or validations added that override or prevent the copying in certain scenarios.

  2. Concurrency or Multi-Threading Issues: Since the field is initially copied but sometimes later set to null, this could be due to another process or thread that clears the field after the shipment is created. This could involve:

    • Another event handler or process that runs after the shipment creation.
    • Customizations that might indirectly affect the CustomerOrderNbr field.
  3. Custom Logic Interference: While you mentioned no direct changes to CustomerOrderNbr in your customizations, it's worth reviewing if any of your custom logic might trigger field updates (even indirectly). For instance:

    • A customization that sets shipment fields could accidentally reset CustomerOrderNbr.
    • A synchronization process could be updating the record after creation.
  4. Database Trigger or Workflow: Sometimes, database triggers or Acumatica workflows might update fields in the background. It’s possible that one of these mechanisms is affecting CustomerOrderNbr.

Debugging and Resolution Approach:

1. Check Core Code Changes in 2024 R1

  • Review Acumatica’s release notes and documentation for 2024 R1, focusing on changes to the Sales Order and Shipment modules. Look for any modifications in the way the system handles field copying, shipment creation, or multi-order shipments.
  • If the issue is confirmed to be caused by an internal core logic change, you may need to apply a support case with Acumatica to get guidance or a patch.

2. Implement a Debugging Hook

You can add custom logging to trace when the CustomerOrderNbr is being set or cleared. This will help identify which part of the process clears the field.

Example:

 

csharp

Copy code

public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry> { protected void _(Events.FieldUpdated<SOShipment, SOShipment.customerOrderNbr> e) { if (e.Row != null && e.NewValue == null) { // Log information or take corrective action PXTrace.WriteInformation($"CustomerOrderNbr was cleared for Shipment {e.Row.ShipmentNbr}"); } } }

3. Check for Custom Code Interference

  • Review your existing customizations for any indirect references to CustomerOrderNbr or any logic that might be updating the SOShipment record after creation.
  • Check for any PXOverride methods related to shipment creation or SOShipment processing that might be affecting this field. Make sure nothing else resets or clears the field after it's initially copied.

4. Ensure No Concurrent Process Clears the Field

Investigate if there are any processes that could be running in the background, such as a synchronization with an external system or an automated workflow that updates shipments after creation. If such a process exists, ensure that it doesn't overwrite the CustomerOrderNbr.

5. Force the Field Population via Customization

You could implement a temporary workaround by overriding the core method that copies the CustomerOrderNbr field, ensuring it's always set when shipments are created.

Example:

 

csharp

Copy code

public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry> { [PXOverride] public bool SetShipmentFieldsFromOrder(SOOrder order, SOShipment shipment, int? siteID, DateTime? shipDate, string operation, SOOrderTypeOperation orderOperation, bool newlyCreated, Func<SOOrder, SOShipment, int?, DateTime?, string, SOOrderTypeOperation, bool, bool> baseMethod) { bool result = baseMethod(order, shipment, siteID, shipDate, operation, orderOperation, newlyCreated); // Ensure the CustomerOrderNbr is always set if (newlyCreated && string.IsNullOrEmpty(shipment.CustomerOrderNbr)) { shipment.CustomerOrderNbr = order.CustomerOrderNbr; Base.Caches[typeof(SOShipment)].Update(shipment); } return result; } }

6. Investigate Company-Specific Settings

Since the issue occurs more frequently in one company than others, check if there are any company-specific settings or workflows that could affect shipment creation. This could include:

  • Shipment processing rules in different companies.
  • Custom workflows or business events that run only in specific companies.

Conclusion:

This issue appears to be a combination of changes in the core logic of Acumatica 2024 R1 and possible interactions with your environment’s customizations. By reviewing core logic changes, adding debugging hooks, and reviewing your custom code, you should be able to pinpoint the exact cause of this sporadic behavior and either resolve it directly or implement a temporary customization as a workaround. If the issue persists, contacting Acumatica support for assistance with core code changes might be necessary.

View original
Did this topic help you find an answer to your question?

3 replies

chameera71
Varsity I
Forum|alt.badge.img+2
  • Varsity I
  • 56 replies
  • Answer
  • September 11, 2024

It seems like you're encountering an issue with the CustomerOrderNbr field not being consistently copied to the shipment record after upgrading to Acumatica 2024 R1. While the behavior is sporadic, it's likely caused by underlying changes in Acumatica's core logic in this version. I'll walk you through some potential causes and approaches to debug and resolve the issue:

Key Observations:

  1. Issue Variability by Company: Since the issue occurs more frequently in one company and sporadically in others, it could be related to data-specific conditions or differences in setup between companies.

  2. Newly Created Shipments: Since this behavior is part of the newly created shipments, and the code reaches the point where OrderDesc is copied to ShipmentDesc, it's likely that the logic affecting CustomerOrderNbr might be conditionally skipped or overwritten after the initial copy.

  3. Core Code Changes in 2024 R1: The issue did not occur before upgrading, suggesting that there may be changes in the core Sales Order/Shipment logic in 2024 R1 that affect how the CustomerOrderNbr field is managed.

Possible Causes:

  1. Core Acumatica Logic Changes: Acumatica 2024 R1 may have modified the core logic that handles the copying of CustomerOrderNbr. Specifically, there could be conditions or validations added that override or prevent the copying in certain scenarios.

  2. Concurrency or Multi-Threading Issues: Since the field is initially copied but sometimes later set to null, this could be due to another process or thread that clears the field after the shipment is created. This could involve:

    • Another event handler or process that runs after the shipment creation.
    • Customizations that might indirectly affect the CustomerOrderNbr field.
  3. Custom Logic Interference: While you mentioned no direct changes to CustomerOrderNbr in your customizations, it's worth reviewing if any of your custom logic might trigger field updates (even indirectly). For instance:

    • A customization that sets shipment fields could accidentally reset CustomerOrderNbr.
    • A synchronization process could be updating the record after creation.
  4. Database Trigger or Workflow: Sometimes, database triggers or Acumatica workflows might update fields in the background. It’s possible that one of these mechanisms is affecting CustomerOrderNbr.

Debugging and Resolution Approach:

1. Check Core Code Changes in 2024 R1

  • Review Acumatica’s release notes and documentation for 2024 R1, focusing on changes to the Sales Order and Shipment modules. Look for any modifications in the way the system handles field copying, shipment creation, or multi-order shipments.
  • If the issue is confirmed to be caused by an internal core logic change, you may need to apply a support case with Acumatica to get guidance or a patch.

2. Implement a Debugging Hook

You can add custom logging to trace when the CustomerOrderNbr is being set or cleared. This will help identify which part of the process clears the field.

Example:

 

csharp

Copy code

public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry> { protected void _(Events.FieldUpdated<SOShipment, SOShipment.customerOrderNbr> e) { if (e.Row != null && e.NewValue == null) { // Log information or take corrective action PXTrace.WriteInformation($"CustomerOrderNbr was cleared for Shipment {e.Row.ShipmentNbr}"); } } }

3. Check for Custom Code Interference

  • Review your existing customizations for any indirect references to CustomerOrderNbr or any logic that might be updating the SOShipment record after creation.
  • Check for any PXOverride methods related to shipment creation or SOShipment processing that might be affecting this field. Make sure nothing else resets or clears the field after it's initially copied.

4. Ensure No Concurrent Process Clears the Field

Investigate if there are any processes that could be running in the background, such as a synchronization with an external system or an automated workflow that updates shipments after creation. If such a process exists, ensure that it doesn't overwrite the CustomerOrderNbr.

5. Force the Field Population via Customization

You could implement a temporary workaround by overriding the core method that copies the CustomerOrderNbr field, ensuring it's always set when shipments are created.

Example:

 

csharp

Copy code

public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry> { [PXOverride] public bool SetShipmentFieldsFromOrder(SOOrder order, SOShipment shipment, int? siteID, DateTime? shipDate, string operation, SOOrderTypeOperation orderOperation, bool newlyCreated, Func<SOOrder, SOShipment, int?, DateTime?, string, SOOrderTypeOperation, bool, bool> baseMethod) { bool result = baseMethod(order, shipment, siteID, shipDate, operation, orderOperation, newlyCreated); // Ensure the CustomerOrderNbr is always set if (newlyCreated && string.IsNullOrEmpty(shipment.CustomerOrderNbr)) { shipment.CustomerOrderNbr = order.CustomerOrderNbr; Base.Caches[typeof(SOShipment)].Update(shipment); } return result; } }

6. Investigate Company-Specific Settings

Since the issue occurs more frequently in one company than others, check if there are any company-specific settings or workflows that could affect shipment creation. This could include:

  • Shipment processing rules in different companies.
  • Custom workflows or business events that run only in specific companies.

Conclusion:

This issue appears to be a combination of changes in the core logic of Acumatica 2024 R1 and possible interactions with your environment’s customizations. By reviewing core logic changes, adding debugging hooks, and reviewing your custom code, you should be able to pinpoint the exact cause of this sporadic behavior and either resolve it directly or implement a temporary customization as a workaround. If the issue persists, contacting Acumatica support for assistance with core code changes might be necessary.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2754 replies
  • October 16, 2024

Hi @chris49 were you able to find a solution? Thank you!


chris49
Varsity II
Forum|alt.badge.img
  • Author
  • Varsity II
  • 54 replies
  • October 17, 2024

Hi @Chris Hackett @chameera71 ,

Apologies for the delayed response here. 

Whilst the answer @chameera71 provided didn’t directly solve my issue, it did inspire me to make some edits in another section of code, which seems to have done the trick. The approach is a bit weird, so I don’t think it’s wise to share the solution.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings