0

I have the following auto-numbering selector defined in my custom DAC:

    #region BatchID
    [PXDBIdentity()]
    public virtual int? BatchID { get; set; }
    public abstract class batchID : PX.Data.BQL.BqlInt.Field<batchID> { }
    #endregion
      
    #region BatchCD
    [PXDBString(15, IsKey = true, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
    [PXUIField(DisplayName = "Batch ID")]
    [AutoNumber(typeof(MXSetup.batchNumberingID), typeof(AccessInfo.businessDate))]
    [PXSelector(typeof(MXBatch.batchID),
        SubstituteKey = typeof(MXBatch.batchCD))]
    public virtual string BatchCD { get; set; }  
    public abstract class batchCD : PX.Data.BQL.BqlString.Field<batchCD> { }
    #endregion 

The auto-numbering works well, but upon selecting an existing record, the displayed value immediately changes back to <NEW>.

Does anyone have an idea why this would be happening?

Deetz
  • 329
  • 1
  • 16
  • Upon further fiddling, I have gotten ``[PXDimensionSelector]`` to work with a segmented key, providing auto-numbering. I don't think I need all the functionality of a segmented key, but it shouldn't hurt. Can anyone say with authority that this IS or IS NOT the correct approach? – Deetz Oct 20 '20 at 15:38

1 Answers1

0

Posting as an answer so my sample code is readable.

The code examples from the Code Repository when I learned to do these always used PXSelector, although I can't say it is wrong to use PXDimensionSelector if that works better for you. However, you should be ok with just plain old PXSelector if it is sufficient.

It may not have any bearing, but does your AutoNumber fit your InputMask? I keep my input mask as "" on this field because it is controlled by the AutoNumber. I also set PXDefault to force it to be required, although that might be overkill. Lastly, I give a little more to the PXSelector to define what shows if someone hits the magnifier. In my case, PXSelector is simple and enough.

Here is one of my simple AutoNumber fields...

#region RequisitionCD
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = "")]
[PXDefault]
[AutoNumber(typeof(SSRQSetup.requisitionNumberingID),
    typeof(AccessInfo.businessDate))]
[PXSelector(
    typeof(SSRQRequisition.requisitionCD),
    typeof(SSRQRequisition.requisitionCD),
    typeof(SSRQRequisition.descr),
    typeof(SSRQRequisition.createdDateTime)
    )]
[PXUIField(DisplayName = Messages.FldRequisitionCD)]
public virtual string RequisitionCD { get; set; }
public abstract class requisitionCD : PX.Data.BQL.BqlString.Field<requisitionCD> { }
#endregion
Brian Stevens
  • 1,826
  • 1
  • 7
  • 16