Skip to main content
Answer

Default Sales Order Shipment Quantity to 0

  • February 11, 2025
  • 3 replies
  • 76 views

Forum|alt.badge.img

Hello Community, 

I was looking for a way to default the shipment quantity to 0 when creating the “Create Shipment” button on Sales Order or from the Process Orders screen. I thought I could just extend the “CreateShipment” method to accomplish this but not having much luck. See below for the code I have. Is there possibly a setting in Acumatica for this I missed or an issue with the code below?

 public delegate void CreateShipmentDelegate(CreateShipmentArgs args);
[PXOverride]
public void CreateShipment(CreateShipmentArgs args, CreateShipmentDelegate baseMethod)
{
// Call the original method to ensure default behavior
baseMethod(args);
Base.Transactions.Current.BaseQty = 0;
Base.Transactions.Current.Qty = 0;
Base.Transactions.Current.ShippedQty = 0;
Base.Transactions.Current.BaseShippedQty = 0;
Base.splits.Current.Qty = 0;
Base.splits.Current.BaseQty = 0;

Base.Transactions.UpdateCurrent();
Base.splits.UpdateCurrent();
}

Thanks,

Adam

Best answer by Ankita Tayana

Hi ​@AJohnson 

Please use below code snippet to make it work as expected.

public delegate void CreateShipmentDelegate(CreateShipmentArgs args);
[PXOverride]
public void CreateShipment(CreateShipmentArgs args, CreateShipmentDelegate baseMethod)
{
// Call the original method
baseMethod(args);

// Ensure all transaction lines have 0 quantity
foreach (SOLine line in Base.Transactions.Select())
{
SOLine updatedLine = Base.Transactions.Cache.CreateCopy(line) as SOLine;
if (updatedLine != null)
{
updatedLine.BaseQty = 0;
updatedLine.Qty = 0;
updatedLine.ShippedQty = 0;
updatedLine.BaseShippedQty = 0;

Base.Transactions.Update(updatedLine);
}
}

foreach (SOLineSplit split in Base.splits.Select())
{
SOLineSplit updatedSplit = Base.splits.Cache.CreateCopy(split) as SOLineSplit;
if (updatedSplit != null)
{
updatedSplit.Qty = 0;
updatedSplit.BaseQty = 0;

Base.splits.Update(updatedSplit);
}
}

// Save changes
Base.Actions.PressSave();
}

 

Hope this helps

3 replies

Forum|alt.badge.img+5
  • Jr Varsity I
  • Answer
  • February 12, 2025

Hi ​@AJohnson 

Please use below code snippet to make it work as expected.

public delegate void CreateShipmentDelegate(CreateShipmentArgs args);
[PXOverride]
public void CreateShipment(CreateShipmentArgs args, CreateShipmentDelegate baseMethod)
{
// Call the original method
baseMethod(args);

// Ensure all transaction lines have 0 quantity
foreach (SOLine line in Base.Transactions.Select())
{
SOLine updatedLine = Base.Transactions.Cache.CreateCopy(line) as SOLine;
if (updatedLine != null)
{
updatedLine.BaseQty = 0;
updatedLine.Qty = 0;
updatedLine.ShippedQty = 0;
updatedLine.BaseShippedQty = 0;

Base.Transactions.Update(updatedLine);
}
}

foreach (SOLineSplit split in Base.splits.Select())
{
SOLineSplit updatedSplit = Base.splits.Cache.CreateCopy(split) as SOLineSplit;
if (updatedSplit != null)
{
updatedSplit.Qty = 0;
updatedSplit.BaseQty = 0;

Base.splits.Update(updatedSplit);
}
}

// Save changes
Base.Actions.PressSave();
}

 

Hope this helps


Forum|alt.badge.img+8
  • Captain II
  • February 12, 2025

HI ​@AJohnson 

 

I have had issues with adding lines with 0 quantity to shipment, these do not always stay on the shipment and can disappear when you save the record.

 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • February 12, 2025

@Ankita Tayana Worked like I needed it to! I had it on a ShipmentEntryExtension so just had to update the tables to SOShipLine and SOShipLineSplit, but still worked perfectly. Thanks for the help!

@aiwan Thanks for the comment, that's actually how I would want it to work. We will be entering the quantities a bit differently so this is perfect!