Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

What is the Best Practice to display number field without a thousands separator (comma or period, depending on locale)?

I have rejected the following ideas:

  1. Text field, because I have to write Validation Rule for number. Performance will be affected.
  2. Phone field, because in case of editing in UI, Salesforce changes 10 digit numbers to match US formatting.

I am looking for best practice, because no clean solution is available. All are dirty solutions.

Edit:

  1. There is no decimal
  2. I won't use the field on VF pages; I'll use the field in reports, and hence don't want the comma in my report tab - if the comma isn't there on the report tab, it won't reflect in the downloaded XLS too
share|improve this question
3  
Do you have Decimal Places = 0? –  mast0r Jan 21 '13 at 11:50
    
@mast0r, no decimal places –  Suman Krishna Saha Jan 22 '13 at 10:40

3 Answers 3

up vote 13 down vote accepted

Create a new custom field, where type is "formula" and the formula return type is "text".

In the formula, use the TEXT() function, and pass the existing number field value into this formula. For example, if your number field is MyNumber_c then your formula would be: TEXT( MyNumber_c )

Your users will enter values into the existing number field, but you can use the formula field (which doesn't display thousands separators) in reports, list views etc.

share|improve this answer

You can use apex:outputText tag to format the output. Try this out:

<apex:outputText value="{0, number, 000000.00}">
   <apex:param value="{!numberfield}" />

share|improve this answer
    
Thank you for your answer, but I need the functionality in downloading XLS reports too. –  Suman Krishna Saha Jan 21 '13 at 12:11
    
well in that case, the best option for you is to have a text field and then a single line validation rule with: (NOT(ISNUMBER(yourStringfield))), show the error message. –  Shailesh Deshpande Jan 21 '13 at 12:26

One thought that comes to mind is to make it a number field data type, but then use Visualforce to render it.

On your Visualforce, bind the output to apex:outputText instead of apex:outputField this should remove all formatting from the number.

It would require a relatively small amount of VF, that you could then embed in a section of your page layout. Still a bit ugly, but it should work.

share|improve this answer
    
Thank you for your answer, but I need the functionality in downloading XLS reports too. –  Suman Krishna Saha Jan 21 '13 at 12:12
1  
You should open a new question for that. Thanks. –  Peter Jan 21 '13 at 12:46
    
Thank you for your suggestion. However, if the comma isn't there on the report tab, it won't reflect in the downloaded XLS too. So no need of opening a new question. –  Suman Krishna Saha Jan 22 '13 at 10:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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