Skip to main content
Answer

Sales Orders raise an error after add new status in Shipment

  • October 9, 2025
  • 5 replies
  • 50 views

Forum|alt.badge.img+1

Hello Guys,

I’m working on an external approval process for my company. It works well. But I found an issue yesterday. When I click Shipment tab in Sales Orders(SO301000) screen, system will pop out an error.

I think the reason is I had add three new statuses in Shipment for the approval process.

 

 

Anyone knows how to fix this? Thank you.

 

Best answer by Django

In the mean time, you can review the answer to the same question I asked a few months ago. The solution worked for me:

 

 

5 replies

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • October 9, 2025

That’s a known issue (AC-352892). It will be fixed in 26r1


Forum|alt.badge.img+7
  • Captain II
  • Answer
  • October 9, 2025

In the mean time, you can review the answer to the same question I asked a few months ago. The solution worked for me:

 

 


Forum|alt.badge.img+1
  • Author
  • Semi-Pro II
  • October 9, 2025

@Dmitrii Naumov Thanks. Do you know any work around solution? 


Forum|alt.badge.img+1
  • Author
  • Semi-Pro II
  • October 9, 2025

@Django Thank you. Let me read your solution. Thanks again. 


Forum|alt.badge.img+1
  • Author
  • Semi-Pro II
  • October 13, 2025

In the mean time, you can review the answer to the same question I asked a few months ago. The solution worked for me:

 

 

Thanks ​@Django . It also works for me. 

I also put my code here for others reference. 

 

Two new code files:

 

Code of SOOrderShipmentStatusAttachedToExt:

using PX.Data;
using PX.Objects.PO;
using PX.Objects.SO;
using System;
using System.Reflection;

namespace SOCustomerApproval.ShipmentStatusFix
{
[PXProtectedAccess]
[PXUIField(DisplayName = "Status", Enabled = false)]
public abstract class SOOrderShipmentStatusAttachedToExt : PXGraphExtension<PX.Objects.SO.GraphExtensions.SOOrderEntryExt.Status, SOOrderEntry>
{
#region Constants
protected const string STATUS_FIELD_NAME = "Status";
protected const string UNKNOWN_STATUS = "Unknown";
#endregion

#region ProtectedAccess
[PXProtectedAccess(typeof(PX.Objects.SO.GraphExtensions.SOOrderEntryExt.Status))]
protected abstract PXFieldState DefaultState(PXCache sender, PXFieldSelectingEventArgs e);

[PXProtectedAccess(typeof(PX.Objects.SO.GraphExtensions.SOOrderEntryExt.Status))]
protected abstract PXFieldState AdjustByAttribute(PXFieldState state, PXUIFieldAttribute uiAttribute);

[PXProtectedAccess(typeof(PX.Objects.SO.GraphExtensions.SOOrderEntryExt.Status))]
protected abstract PXFieldState AdjustStateBySelf(PXFieldState state);

[PXProtectedAccess(typeof(PX.Objects.SO.GraphExtensions.SOOrderEntryExt.Status))]
protected abstract PXFieldState AdjustStateByRow(PXFieldState state, SOOrderShipment row);
#endregion

#region Properties
protected PXUIFieldAttribute FieldAttribute => GetType().GetCustomAttribute<PXUIFieldAttribute>();
protected virtual bool SuppressValueSetting => false;
protected virtual String ValueForEmptyRow => default(String);
#endregion

#region Initialization
public override void Initialize()
{
try
{
Base.Caches<SOOrderShipment>().Fields.Add(STATUS_FIELD_NAME);
Base.FieldSelecting.AddHandler(typeof(SOOrderShipment), STATUS_FIELD_NAME, FieldSelecting);
}
catch (Exception ex)
{
PXTrace.WriteError($"Failed to initialize SOOrderShipmentStatusAttachedToExt: {ex.Message}");
}
}
#endregion

#region Event Handlers
public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{
try
{
PXFieldState state = DefaultState(sender, e);

if (FieldAttribute != null)
{
state = AdjustByAttribute(state, FieldAttribute);
}

state = AdjustStateBySelf(state);
state = AdjustStateByRow(state, (SOOrderShipment)e.Row);
e.ReturnState = state;

if (!SuppressValueSetting)
{
e.ReturnValue = ((e.Row == null) ? ValueForEmptyRow : GetValue((SOOrderShipment)e.Row, sender));
}
}
catch (Exception ex)
{
PXTrace.WriteError($"Error in FieldSelecting: {ex.Message}");
e.ReturnValue = UNKNOWN_STATUS;
}
}
#endregion

#region Core Logic
public virtual string GetValue(SOOrderShipment row, PXCache sender)
{
if (row == null) return UNKNOWN_STATUS;

try
{
if (row.ShipmentType == SOShipmentType.DropShip)
{
return GetDropShipStatus(row);
}
else
{
return GetStandardShipStatus(row);
}
}
catch (Exception ex)
{
PXTrace.WriteError($"Error getting shipment status for {row.ShipmentNbr}: {ex.Message}");
return UNKNOWN_STATUS;
}
}

protected virtual string GetDropShipStatus(SOOrderShipment row)
{
using var receipt = PXDatabase.SelectSingle<POReceipt>(
new PXDataField<POReceipt.status>(),
new PXDataFieldValue<POReceipt.receiptType>(
PXDbType.Char, null,
row.Operation == SOOperation.Issue ? POReceiptType.POReceipt : POReceiptType.POReturn,
PXComp.EQ),
new PXDataFieldValue<POReceipt.receiptNbr>(
PXDbType.NVarChar, null, row.ShipmentNbr, PXComp.EQ));

if (receipt == null)
{
return null;
}

string statusValue = receipt.GetString(0);
var statusDic = (new POReceiptStatus.ListAttribute()).ValueLabelDic;

return GetStatusDisplayText(statusValue, statusDic);
}

protected virtual string GetStandardShipStatus(SOOrderShipment row)
{
using (new PXReadThroughArchivedScope())
{
using var shipment = PXDatabase.SelectSingle<SOShipment>(
new PXDataField<SOShipment.status>(),
new PXDataFieldValue<SOShipment.shipmentType>(
PXDbType.Char, null, row.ShipmentType, PXComp.EQ),
new PXDataFieldValue<SOShipment.shipmentNbr>(
PXDbType.NVarChar, null, row.ShipmentNbr, PXComp.EQ));

if (shipment != null)
{
string statusValue = shipment.GetString(0);

var statusDic = (new SOShipmentStatusExt.ListAttribute()).ValueLabelDic;

return GetStatusDisplayText(statusValue, statusDic);
}
else
{
return PXMessages.LocalizeNoPrefix(PX.Objects.SO.Messages.AutoGenerated);
}
}
}

protected virtual string GetStatusDisplayText(string statusValue, System.Collections.Generic.IDictionary<string, string> statusDictionary)
{
if (string.IsNullOrEmpty(statusValue))
{
return UNKNOWN_STATUS;
}

if (statusDictionary != null && statusDictionary.ContainsKey(statusValue))
{
return statusDictionary[statusValue];
}
else
{
PXTrace.WriteWarning($"Status value '{statusValue}' not found in status dictionary");
return statusValue ?? UNKNOWN_STATUS;
}
}
#endregion
}
}

 

Code of SOShipmentStatusExt:

using PX.Data;

namespace SOCustomerApproval.ShipmentStatusFix
{
public class SOShipmentStatusExt
{
public const string CustomerApproved = "V";
public const string CustomerRejected = "J";
public const string PendingCustomerApproval = "P";

public class customerApproved : PX.Data.BQL.BqlString.Constant<customerApproved>
{
public customerApproved() : base(CustomerApproved) { }
}

public class customerRejected : PX.Data.BQL.BqlString.Constant<customerRejected>
{
public customerRejected() : base(CustomerRejected) { }
}

public class pendingCustomerApproval : PX.Data.BQL.BqlString.Constant<pendingCustomerApproval>
{
public pendingCustomerApproval() : base(PendingCustomerApproval) { }
}

public class ListAttribute : PXStringListAttribute
{
public ListAttribute() : base(
new[]
{
Pair(CustomerApproved, "Customer Approved"),
Pair(CustomerRejected, "Customer Rejected"),
Pair(PendingCustomerApproval, "Pending Customer Approval")
})
{
}

}
}
}

 

Now the status showing well on Sales Orders screen under Shipments tab.