Skip to main content
Solved

Duplicate row and PXDefault reset when changing CountryID on custom grid (TwTransportThl in POOrderEntry)

  • October 16, 2025
  • 4 replies
  • 74 views

Hi everyone,

I’m facing a strange issue in a customization for POOrderEntry.
I have a custom DAC TwTransportThl linked to POOrder by OrderType/OrderNbr, displayed in a grid under a “Transport” tab.
The DAC includes fields like CountryID, State, AddressLine1, TransportType, etc.

The behavior:

When I change CountryID the first time  everything works fine, one row is updated and TransportType stays as selected.

When I change CountryID again and saves the grid suddenly shows two rows  and TransportType resets to the default value “LO” (from [PXDefault]).
If I delete that default, the field becomes empty.

Tseems related to postback/CommitChanges

Best answer by darylbowman

I’m not certain this is the problem either, but usually when [PXLineNbr] is used, it’s used with a BQL field type instead of just a DAC type (as the parameter). It usually points to a field on the parent DAC that stores the counted lines. I did see it used the way you’re using a couple places in the source code, but since POOrder already uses the line counting mechanism, this might be interfering with the Details lines. Also, I think in order for the PXLineNbr to work, you need to use [PXParent]. I forget if you’re doing that.

Here’s an example from the source code:

#region LineNbr
/// <summary>
/// The order line number.
/// </summary>
[PXDBInt(IsKey = true)]
[PXDefault()]
[PXUIField(DisplayName ="Line Nbr." , Visible =false)]
[PXLineNbr(typeof(SOOrder.riskLineCntr))]
[PXParent(typeof(Select<SOOrder, Where<SOOrder.orderType, Equal<Current<SOOrderRisks.orderType>>,
And<SOOrder.orderNbr, Equal<Current<SOOrderRisks.orderNbr>>
>>>))]
public virtual Int32? LineNbr { get; set; }
/// <inheritdoc cref="LineNbr" />
public abstract class lineNbr : PX.Data.BQL.BqlInt.Field<lineNbr> { }
#endregion

 

4 replies

darylbowman
Captain II
Forum|alt.badge.img+16

There’s no point in including OrderType and OrderNbr as part of the ‘key’ if you’re also using an auto-generated ID since you’ll always have a unique key regardless. But that’s not your problem.

Have you checked that LineNbr is working correctly? (I’m assuming you’re needing this to generate a line nbr and not simply storing a POLine nbr?)

Have you tried debugging to check key field info?


  • Author
  • Freshman I
  • October 16, 2025

Thanks for the reply — you’re right, every time I change CountryID, Acumatica inserts a new row in the cache with a new LineNbr, so the framework treats it as a new record instead of updating the existing one. But I dont know how I should set line nbr so 

There’s no point in including OrderType and OrderNbr as part of the ‘key’ if you’re also using an auto-generated ID since you’ll always have a unique key regardless. But that’s not your problem.

Have you checked that LineNbr is working correctly? (I’m assuming you’re needing this to generate a line nbr and not simply storing a POLine nbr?)

Have you tried debugging to check key field info?

Thanks for the reply — you’re right, every time I change CountryID, Acumatica inserts a new row in the cache with a new LineNbr , so the framework treats it as a new record instead of updating the existing one. But I dont know how I should set line nbr so that when I choose from selector to update current line instead of adding a new one.


darylbowman
Captain II
Forum|alt.badge.img+16
  • Answer
  • October 16, 2025

I’m not certain this is the problem either, but usually when [PXLineNbr] is used, it’s used with a BQL field type instead of just a DAC type (as the parameter). It usually points to a field on the parent DAC that stores the counted lines. I did see it used the way you’re using a couple places in the source code, but since POOrder already uses the line counting mechanism, this might be interfering with the Details lines. Also, I think in order for the PXLineNbr to work, you need to use [PXParent]. I forget if you’re doing that.

Here’s an example from the source code:

#region LineNbr
/// <summary>
/// The order line number.
/// </summary>
[PXDBInt(IsKey = true)]
[PXDefault()]
[PXUIField(DisplayName ="Line Nbr." , Visible =false)]
[PXLineNbr(typeof(SOOrder.riskLineCntr))]
[PXParent(typeof(Select<SOOrder, Where<SOOrder.orderType, Equal<Current<SOOrderRisks.orderType>>,
And<SOOrder.orderNbr, Equal<Current<SOOrderRisks.orderNbr>>
>>>))]
public virtual Int32? LineNbr { get; set; }
/// <inheritdoc cref="LineNbr" />
public abstract class lineNbr : PX.Data.BQL.BqlInt.Field<lineNbr> { }
#endregion

 


  • Author
  • Freshman I
  • October 17, 2025

I’m not certain this is the problem either, but usually when [PXLineNbr] is used, it’s used with a BQL field type instead of just a DAC type (as the parameter). It usually points to a field on the parent DAC that stores the counted lines. I did see it used the way you’re using a couple places in the source code, but since POOrder already uses the line counting mechanism, this might be interfering with the Details lines. Also, I think in order for the PXLineNbr to work, you need to use [PXParent]. I forget if you’re doing that.

Here’s an example from the source code:

#region LineNbr
/// <summary>
/// The order line number.
/// </summary>
[PXDBInt(IsKey = true)]
[PXDefault()]
[PXUIField(DisplayName ="Line Nbr." , Visible =false)]
[PXLineNbr(typeof(SOOrder.riskLineCntr))]
[PXParent(typeof(Select<SOOrder, Where<SOOrder.orderType, Equal<Current<SOOrderRisks.orderType>>,
And<SOOrder.orderNbr, Equal<Current<SOOrderRisks.orderNbr>>
>>>))]
public virtual Int32? LineNbr { get; set; }
/// <inheritdoc cref="LineNbr" />
public abstract class lineNbr : PX.Data.BQL.BqlInt.Field<lineNbr> { }
#endregion

 

I changed lineNbr like this, and it seems fine for now. Thank you!

   [PXDBInt(IsKey = true)]
   [PXDefault()]
   [PXUIField(DisplayName = "Line Nbr.", Visible = false)]
   [PXLineNbr(typeof(POOrderTwExt.usrTransportLineCntr))]
   [PXParent(typeof(Select<POOrder, Where<POOrder.orderType, Equal<Current<orderType>>, And<POOrder.orderNbr, Equal<Current<orderNbr>>>>>))]
   public int? LineNbr { get; set; }
   public abstract class lineNbr : BqlInt.Field<lineNbr> { }

and on POOrder

    [PXDBInt]
    [PXDefault(0)]
    [PXUIField(DisplayName = "Transport Line Cntr", Visible = false)]
    public int? UsrTransportLineCntr { get; set; }
    public abstract class usrTransportLineCntr : PX.Data.BQL.BqlInt.Field<usrTransportLineCntr> { }