Display decimals for amount field on List

Help please!

I have an Amount field on a list page.  The underlying data in the table which produces the list indicates the value goes out two decimal places.  (Ex.  18,947.67)

However, on the list it is displayed as $18,948.

On an entry screen, when I need to display the decimal and the user preference is set to 0, I have used this in the create script of the field.

CRM.UserOption("OldDecimalPlaces") = CRM.UserOption("NSet_DecimalPlaces");
CRM.UserOption("NSet_DecimalPlaces") = 2;

and then this on the last field of the screen..

CRM.UserOption("OldDecimalPlaces") = CRM.UserOption("NSet_DecimalPlaces");
CRM.UserOption("NSet_DecimalPlaces") = 0;

However, this is not working for me for a list.

I updated the user preference to display 2 decimal places in hopes that this would cause the amount to properly display on the list.  However, the value is still displaying without decimals.

The page is being generated by a .net dll.  Therefore, I am not able to go into an asp page and make modifications.

Is there something I can add to the custom content area to get the value to show with two decimal places?  If so, can someone shove me in the right direction.

Any assistance would be greatly appreciated.

THank you!

Parents
  • 0

    With the number of decimal places set to zero, floating point numbers will be rounded to the nearest integer.

    When I need to have more decimal places than the set number I use a text field to store the string equivalent of the number.  The string then needs to be converted into a number if calculations are to be done.  In your case where you don't have access to the dll code I would create a new text field and add a table script to convert the numeric value to a string and save it in the new field. 

    Eg if the numeric field is called 'enty_quantity' and the new text field is called 'enty_quantitystr' then in the tls Insert() and Update() functions add:

    Values("enty_quantitystr") = Values("enty_quantity").toFixed(2); 

    Use the text field in your list screen instead of the numeric.

    You will need to initialise the new field with the string equivalents of the numeric values in SSMS.  From then on the text field will be updated from the numeric field when a record is saved.

  • 0 in reply to Paul C

    Paul C:  Thank you!  This solution makes sense to me!  I also like it because it will hold after an upgrade.  I am going to give this a go today.  I will let you know if it works out for me.

    Again, thank you!

Reply Children
No Data