1

As far as I can tell, I have set this auto numbering field up correctly. I've done multiple auto numbering setups in the past, but this one does not seem to want to work, and I cannot see why.

This is the DAC object to store the auto numbering:

[PXDBString(15, IsUnicode = true, InputMask = "")]
[PXSelector(typeof(Numbering.numberingID), DescriptionField = typeof(Numbering.descr))]
[PXUIField(DisplayName = "Catalog Header Nbr")]
public virtual string CatalogHeaderNbr { get; set; }
public abstract class catalogHeaderNbr : IBqlField { }

This is assigning it to the CD field:

[PXDBString(15, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC", IsKey = true)]
[AutoNumber(typeof(CFBSNumberingSetup.catalogHeaderNbr), typeof(AccessInfo.businessDate))]
[PXUIField(DisplayName = "Catalog ID")]
[PXDefault]
[PXSelector(typeof(Search<CFBSCatalogHeader.catalogCD>),
    new Type[]
    {
        typeof(CFBSCatalogHeader.catalogCD),
        typeof(CFBSCatalogHeader.vendorID),
        typeof(CFBSCatalogHeader.descr)
    },
    DescriptionField = typeof(CFBSCatalogHeader.catalogCD)
    )]

public virtual string CatalogCD { get; set; }
public abstract class catalogCD : IBqlField { }

Numbering Sequence screen (Please note the symbol I have is NEW):

enter image description here

Numbering Setup page I made that has the assigned stored value:

enter image description here

Error I get when I save (Note the symbol says SELECT instead of NEW):

enter image description here

Error Trace:

11/7/2018 10:19:34 AM Error: Value cannot be null. Parameter name: format

at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.Format(String format, Object[] args) at PX.Data.PXMessages.LocalizeFormat(String strMessage, String& MessagePrefix, Object[] args) at PX.Data.PXException..ctor(String format, Object[] args) at PX.Objects.CS.AutoNumberAttribute.RowPersisting(PXCache sender, PXRowPersistingEventArgs e) in F:\Bld\AC-FULL2018R112-JOB1\sources\WebSites\Pure\PX.Objects\CS\Descriptor\Attribute.cs:line 2808 at PX.Data.PXCache.OnRowPersisting(Object item, PXDBOperation operation) at PX.Data.PXCache`1.PersistInserted(Object row) at PX.Data.PXCache`1.Persist(PXDBOperation operation) at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation) at PX.Data.PXGraph.Persist() at PX.Data.PXSave`1.d__2.MoveNext() at PX.Data.PXAction`1.d__31.MoveNext() at PX.Data.PXAction`1.d__31.MoveNext() at PX.Web.UI.PXBaseDataSource.tryExecutePendingCommand(String viewName, String[] sortcolumns, Boolean[] descendings, Object[] searches, Object[] parameters, PXFilterRow[] filters, DataSourceSelectArguments arguments, Boolean& closeWindowRequired, Int32& adapterStartRow, Int32& adapterTotalRows) at PX.Web.UI.PXBaseDataSource.ExecuteSelect(String viewName, DataSourceSelectArguments arguments, PXDSSelectArguments pxarguments)

EricP.
  • 489
  • 3
  • 21

2 Answers2

3

Make sure you have a PXSetup view for your setup table in your graph using this numbering sequence. From the look of the screen shots its not finding the numbering sequence you expect because the new symbol is not the symbol you are expecting. This could be the lack of setup due to missing the PXSetup view.

In post How to implement auto generating document number on custom screen it references: "Make sure in the graph building the documents to include a PXSetup view to the setup table."

Brendan
  • 5,428
  • 2
  • 17
  • 33
  • I knew it was going to be something small I was missing... Gotta love when you can't see the small things you are missing when reviewing your own code. – EricP. Nov 12 '18 at 16:14
  • i can agree to that. sometimes just having someone with an outside perspective helps (asking a question here on stackoverflow). Glad you got it resolved. – Brendan Nov 12 '18 at 17:40
  • Seriously this keeps getting me every time! Even today! – EricP. May 07 '20 at 20:23
0

You may wish to try handling the assignment during RowPersisting, such as:

    public virtual void DAC_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
    {
        DAC record = (DAC)e.Row;
        if (record != null)
        {
            if (this.DAC.Cache.GetStatus(record) == PXEntryStatus.Inserted)
            {
                string nextNumber = AutoNumberAttribute.GetNextNumber
        (DAC.Cache, record, "CATHEADNBR", DateTime.Now);
                record.CatalogCD = nextNumber;
            }
        }
    }
FarmerJohn
  • 367
  • 2
  • 8
  • I was trying to avoid that since the base functionality automatically populates the ID instead of forcing me to do it manually. If no one has a solution as to why this particular auto numbering isn't automatically populating, I'll go down that route. Do you know if there is a way to force the – EricP. Nov 07 '18 at 18:52