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.

How is this possible?

I would assume a VisualForce email template would by default display it to the number of decimal places it is defined as?

How in this instance can it display a value that is stored to 6 decimal places, to 13 decimal places?

enter image description here

Email Template code:

    <p style="padding: 10px 30px 10px 30px; margin: 10px;">
        Utilization:
        <b>{!relatedTo.Blah__UtilisationPercentage__c}</b><br />
    </p>
share|improve this question
1  
Can you share some of your Visualforce code and maybe a screenshot of your field definition please? –  Andrew Fawcett Feb 13 at 9:46
    
I've tried to do this. The image has come out unreadably small, but it's fine if you open it in a new tab. Thanks. –  finisterre Feb 13 at 10:08
    
No problem, I think I've spotted your problem, give it a go. :-) –  Andrew Fawcett Feb 13 at 10:09

1 Answer 1

up vote 3 down vote accepted

Salesforce numeric values are actually stored as generic decimal types internally, i suspect by making a raw/direct binding to the field your simply exposing this value unformatted. The recommended approach for outputting field values is to use apex:outputField, this will handle the correct formatting and localisation of the value (commas, thousand separators). Try this...

<apex:outputField value="{!relatedTo.Blah__UtilisationPercentage__c}"/>

A read-only display of a label and value for a field on a Salesforce object. An apex:outputField component respects the attributes of the associated field, including how it should be displayed to the user

share|improve this answer
    
Thanks. Tried this. Works! The HTML part of my template now displays to 6 DP. Interestingly, I notice that the plain text part of the template, which is still using the old method e.g. Utilization: {!relatedTo.Blah__UtilisationPercentage__c displays 100% as 100.0%. So there seems to be inconsistent behaviour here. –  finisterre Feb 13 at 10:21
    
@finisterre please upvote and mark as answered if that helps you ,so that its beneficial for other users . –  Mohith Shrivastava Feb 13 at 10:31

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.