Skip to main content
Answer

Recording whole number without decimal in a field

  • September 29, 2022
  • 3 replies
  • 334 views

Hello all,

 

Is there a way to make in input field that currently takes decimal number to take only a whole number?  We have a few fields that are only used to record output quantity and scrap.  To reduce errors i would like to remove decimal places as we would never scrap part of something.  example We output 16 we scrap 3. 

Thank for any help you can provide.

Best answer by deybanperez

Yes, you can define the PXDecimal attribute of the field in the following way:
 

[PXDBDecimal(0)]

 

The PXDBDecimal attribute constructor has a parameter called Precision, you can use it to define how many decimals you want to display in the interface and how many decimals you want to handle when using that field. The precision must be <= than the defined in the DB Schema.

 


Ex.

Before:

[PXDBDecimal(2)]



After:
 

[PXDBDecimal(0)]

 




 

3 replies

Vinay Koppula
Semi-Pro II
Forum|alt.badge.img+1
  • Semi-Pro II
  • September 30, 2022

Hi @jmeagher, You have used PXDBDecimalAttribute for those fields in the DAC, correct me if I’m wrong. If so, then use PXDBIntAttribute instead PXDBDecimalAttribute. This should resolve your issue. 

 

Since you are changing the datatype you have to write a script to change the DataType from Decimal to Int in the DB as well. 


deybanperez
Jr Varsity III
  • Jr Varsity III
  • Answer
  • September 30, 2022

Yes, you can define the PXDecimal attribute of the field in the following way:
 

[PXDBDecimal(0)]

 

The PXDBDecimal attribute constructor has a parameter called Precision, you can use it to define how many decimals you want to display in the interface and how many decimals you want to handle when using that field. The precision must be <= than the defined in the DB Schema.

 


Ex.

Before:

[PXDBDecimal(2)]



After:
 

[PXDBDecimal(0)]

 




 


  • Author
  • Freshman I
  • October 3, 2022

Thank you both for responding to my thread, I am trying to learn more and more of the customizations I can do to help the company I work for.