2

I've few custom fields on Account object, which user will drag on to the Account Layout page by customizing it.

I'd like to control the formatting of these fields on the layout.

For example one of my fields is of numeric(18,0) type, and I'd like it to be displayed without the thousand separator. And for some should add the trailing zeros if needed to show two digits after the decimal point.

How can I do this when I'm not using a VisualForce page?

1

It is not an elegant solution, but if the fields are read-only, then you can create a formula field that calculates the formatted version of the underlying value (and uses the same label text) and use that.

If the fields are editable I think you are out of luck.

2
  • Thanks, fields are readonly, but there are more than 20 such fields, I don't want to create a formula field for each of those, as it will clutter the field list. Can I use a formula to change the display value on the same field? – BuddhiP Mar 1 '14 at 15:15
  • You cannot use a formula to change the display value on the same field. Putting "view" logic in the model is wrong but the platform doesn't give you much choice - creating extra fields is a relatively common work-around. Agree duplication is clutter, but if this is a once off it is only 30 minutes work. – Keith C Mar 1 '14 at 15:45
0

You'd need to change the the field setting to Numeric(15,3) to always display that field to the thousandth-decimal-place.

If you only need two decimal places, try (16,2).

Here's how it works: you get 18 total decimal places for a decimal-type field (in Apex, all Numbers/Currencies are of the decimal type). Whenever you define a decimal-type field, you have to give it two parmeters (x,y) -- the first parameter, x, is how many digits you want show to the left of the decimal point, and the second parameter, y, is the number of digits shown to the right of the decimal point. And remember, you get a total of 18 to play with.


Just to note, in Apex Controllers and Visualforce pages, there's always some way you can process your data into the desired format (in Apex Controllers) or often the formatting can take place in the Visualforce page itself.

1
  • I have tried the solution provided. I had field for year as with Number(4,0) and tried changing it (2,2) it doesn't work that way. So I had an issue to remove the "," from the year so that it shows it as 2014 and not 2,104. The above solution is not working – user7119 Feb 28 '14 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.