Skip to main content
Solved

How to stop showing negative initial value in Auto Increment Identity Field


Forum|alt.badge.img+1

Hi all,

I have defined a key field in my newly created DAC as follows

#region RefNbr
 [PXDBIdentity(IsKey = true)]
 [PXUIField(DisplayName = "Ref Nbr")]
 public virtual int? RefNbr{ get; set; }
 public abstract class refNbr: PX.Data.BQL.BqlInt.Field<refNbr> { }
#endregion

 

This is how I defined it in DB Script

RefNbr INT NOT NULL AUTO_INCREMENT UNIQUE,

 

In my Screen it shows Like this initially before record is saved. But After it is saved it shows the actual RefNbr like (1,2,3….)

 

How can I stop showing this as a negative value. Can I show that as <New> instead of this negative value before saving the record.

 

Thanks

Best answer by darylbowman

In most Acumatica screens, you won’t see the primary key field. You will instead see the substitute key. BAccount.AcctCD instead of BAccount.BAccountID, for instance.

This is another option.

 

An overload of additional info here.

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+5
  • Captain II
  • 509 replies
  • September 26, 2023

 You might try something like this:

protected virtual void _(Events.FieldSelecting<DAC, DAC.theField> e)
{
	DAC row = e.Row;
	if (row is null) return;

    if (row.TheField == null)
    {
      e.ReturnValue = "<NEW>";
    }
    else
    {
      e.ReturnValue = row.TheField;
    }

}

darylbowman
Captain II
Forum|alt.badge.img+13
  • 1608 replies
  • Answer
  • September 26, 2023

In most Acumatica screens, you won’t see the primary key field. You will instead see the substitute key. BAccount.AcctCD instead of BAccount.BAccountID, for instance.

This is another option.

 

An overload of additional info here.


Forum|alt.badge.img+1

@Django @darylbowman  Thank you so much for your responses. Showing <New> was not succeeded,  I had to go with substitute key option.

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings