Skip to main content
Question

SOOrderEntry CreateShipmentIssue fails with CuryID cannot be empty

  • July 13, 2026
  • 1 reply
  • 19 views

Forum|alt.badge.img+1

I’m trying to programatically created Sales Shipments: given a despatch message from the third-party warehouse, I locate the sales order and then use CreateShipmentIssue to construct the shipment.

This works fine when I run the action as a user. But fails every time when running as a Process via the automation scheduler.

My code simplifies to:

orderGraph.Clear();
orderGraph.Document.Current = PXSelect<SOOrder,Where<SOOrder.orderNbr,Equal<Required<SOOrder.orderNbr>>>>.Select(orderGraph, orderNbr);

PXAdapter adapter = new PXAdapter(PXView.Dummy.For<SOOrder>(orderGraph)) { AllowRedirect = false, MassProcess = false };
var orders = orderGraph.CreateShipmentIssue(adapter, receivedItem.ShippedDate, siteID, DateTime.UtcNow);

The error is:

PX.Data.PXRowPersistingException: Error: 'CuryID' cannot be empty.
   at PX.Data.PXDefaultAttribute.RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
   at PX.Data.PXCache.AttributeHandlersSquasher`1.<>c__DisplayClass2_0`1.<To>b__0(PXCache cache, TArgs args)
   at PX.Data.PXCache.OnRowPersisting(Object item, PXDBOperation operation)
   at PX.Data.PXCache`1.PersistInserted(Object row, Boolean bypassInterceptor)
   at PX.Data.PXCache`1.Persist(PXDBOperation operation)
..

   at Wrapper.PX.Objects.SO.Cst_SOOrderEntry.CreateShipment(PXAdapter adapter, Nullable`1 shipDate, Nullable`1 siteID, Nullable`1 endDate, String operation)
   at PX.Objects.SO.SOOrderEntry.CreateShipmentIssue(PXAdapter adapter, Nullable`1 shipDate, Nullable`1 siteID, Nullable`1 endDate)
 

 

What might I have missed? (I know that when the process runs it’s as the admin user and the Branch won’t get set from the user default, but surely the Branch would be taken from the Sales Order?)

1 reply

Forum|alt.badge.img+1
  • Varsity III
  • July 13, 2026

Hello ​@allisterchambers48 ,

Recommended Code Fix
To resolve this, you must explicitly set the graph's branch context to match the branch of the Sales Order before calling the shipment creation logic.
 


orderGraph.Clear();
// Select the Sales Order
SOOrder order = PXSelect<SOOrder, Where<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>.Select(orderGraph, orderNbr);
orderGraph.Document.Current = order;

// EXPLICIT FIX: Set the session branch ID in the graph context to match the order
if (order != null)
{
orderGraph.AccessInfo.BranchID = order.BranchID;
}

PXAdapter adapter = new PXAdapter(PXView.Dummy.For<SOOrder>(orderGraph)) { AllowRedirect = false, MassProcess = false };
var orders = orderGraph.CreateShipmentIssue(adapter, receivedItem.ShippedDate, siteID, DateTime.UtcNow);

Additional Troubleshooting Steps

  • Assign a Default Branch to the Admin user to ensure scheduled processes have a valid branch context.
  • Verify that the selected Branch has a Base Currency configured (if Multi-Currency Accounting is enabled).
  • Confirm that the Customer has a default Currency ID configured on the Financial tab.