unable to show decimals upto 3 digits, even though after keeping the scale attribute to 3

sri vyshnavi
Tera Expert

Hi,

 

I'm unable to show field value upto three decimals, on decimal type field. I added scale attribute to 3 and maxlenghth is set as 25. Still it is not working. It is showing only upto 2 decimals.

For Ex: If I put the value as 0.003. It is rounding of to 0. Here I want it as 0.003

If I put the value 0.032. It is rounding of to 0.03. Here I want it as 0.032.

 

Please give me solution without changing the type of the field.

 

Thanks in advance.

 

 

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Sri,

Check for article once.

View solution in original post

4 REPLIES 4

Jaspal Singh
Mega Patron
Mega Patron

Hi Sri,

Check for article once.

Community Alums
Not applicable

Hi @sri vyshnavi ,

This is expected behaviour. The max length value needs to be changed at the same time as the scale value in order to have the correct values at the database level. If you change the scale alone then the DB does not reflect the change, which means the default values are still used.

 

  1. Open the Advanced view of the dictionary entry for the Decimal field of your table
  2. Add "scale=5" (or another number) to the attributes field
  3. Click on "Save"
  4. Modify the field value of "Max length" to something different than it currently is (the default is 20)
  5. Click on "Save"

 

If you created a new column of type decimal and don’t set the scale initially, it will default to 2.
If you then change the scale value to another number then you need to change the max length value twice in order to have the DB reflect the scale value.

 

Community Alums
Not applicable

This is taken from the same Article mentioned by @Jaspal Singh 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @sri vyshnavi 

 

Workaround

This is expected behaviour. The max length value needs to be changed at the same time as the scale value in order to have the correct values at the database level. If you change the scale alone then the DB does not reflect the change, which means the default values are still used.

 

  1. Open the Advanced view of the dictionary entry for the Decimal field of your table
  2. Add "scale=5" (or another number) to the attributes field
  3. Click on "Save"
  4. Modify the field value of "Max length" to something different than it currently is (the default is 20)
  5. Click on "Save"

 

If you created a new column of type decimal and don’t set the scale initially, it will default to 2.
If you then change the scale value to another number then you need to change the max length value twice in order to have the DB reflect the scale value.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************