function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Matthew AllenMatthew Allen 

changing text format in Visualforce to currency

Hi,

I have some visualforce code that I noticed was returning some strange formatting. I think it's becuase I am referencing some number and currency fields as text so it was coming back as 0.0 instead of 0. It also had no £ at the beginning.
I have looked at trying to edit this myself but have had no luck.

Can you help?
 
<apex:outputText label="AccNAme" value="{!IF(Field1 = "Group",Field2,Field3)}" /></apex:outputLabel>
Thank you

Matt
 
Best Answer chosen by Matthew Allen
Khan AnasKhan Anas (Salesforce Developers) 
I checked below code in my org and it is not showing any error:
 
<td style="width:10%"><apex:image id="Picture" value="{!If(Field1 >0, $Resource.Picture1, $Resource.Picture2)}" width="200" height="80"/></td>
        
<td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853893000/Picture4" width="175" height="70"/></td>
        
<td style="width:20%">
    <apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Field1 >0, '#3BB97C', '#d9d9d9')};"/>
    <apex:outputText label="AccNAme" value="{0, Number, Currency}" >
        <apex:param value="{!IF(RecordType="Group",Field2,Field3)}" />
    </apex:outputText>
</td>

 

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Matthew,

Greetings to you. It is a pleasure to be in touch with you again.

You can use something like this:
 
<apex:outputText label="AccName" value="{0, Number, Currency}" >
        <apex:param value="{!IF(Field1 = "Group",Field2,Field3)}" />
</apex:outputText>


I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.

Thanks and Regards,
Khan Anas
Matthew AllenMatthew Allen
Hi Khan,

Thanks again for your help, however I am getting an error saying it needs to be terminated using OutputText which appears t obe what you have done?

I thought maybe given you a bit more code may help?
 
<td style="width:10%"><apex:image id="Picture" value="{!If(Field1 >0, $Resource.Picture1, $Resource.Picture2)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853893000/Picture4" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Field1 >0, '#3BB97C', '#d9d9d9')};">
    <apex:outputText label="AccNAme" value="{0, Number, Currency}" ><apex:param value=" {!IF(RecordType="Group",Field2,Field3)}" /></apex:outputtext></td>
Thank you so much for your help
 
Khan AnasKhan Anas (Salesforce Developers) 
Matthew,

I think you missed to close outputLabel tag:
 
<td style="width:10%"><apex:image id="Picture" value="{!If(Field1 >0, $Resource.Picture1, $Resource.Picture2)}" width="200" height="80"/></td>
        <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853893000/Picture4" width="175" height="70"/></td>
        <td style="width:20%">
            <apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Field1 >0, '#3BB97C', '#d9d9d9')};">
            	<apex:outputText label="AccNAme" value="{0, Number, Currency}" >
                	<apex:param value=" {!IF(RecordType="Group",Field2,Field3)}" />
            	</apex:outputText>
            </apex:outputLabel>
        </td>

I hope it helps you.

Kindly mark this as solved if the information was helpful.​

Regards,
Khan Anas
Matthew AllenMatthew Allen
I am stil getting the same error?
 
<td style="width:10%"><apex:image id="Picture" value="{!If(Field1 >0, $Resource.Picture1, $Resource.Picture2)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853893000/Picture4" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Field1 >0, '#3BB97C', '#d9d9d9')};">
    <apex:outputText label="AccNAme" value="{0, Number, Currency}" ><apex:param value=" {!IF(RecordType="Group",Field2,Field3)}" /></apex:outputtext></apex:outputLabel></td>

 
Khan AnasKhan Anas (Salesforce Developers) 
I checked below code in my org and it is not showing any error:
 
<td style="width:10%"><apex:image id="Picture" value="{!If(Field1 >0, $Resource.Picture1, $Resource.Picture2)}" width="200" height="80"/></td>
        
<td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853893000/Picture4" width="175" height="70"/></td>
        
<td style="width:20%">
    <apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Field1 >0, '#3BB97C', '#d9d9d9')};"/>
    <apex:outputText label="AccNAme" value="{0, Number, Currency}" >
        <apex:param value="{!IF(RecordType="Group",Field2,Field3)}" />
    </apex:outputText>
</td>

 
This was selected as the best answer
Matthew AllenMatthew Allen
ok, so that final code you sent has fixed the error - so thank you very much again.. however. Tghe output of the field is ignoring the formatting and also has a $ sign instead of a £ sign?

it is ignoring this bit -
style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Field1 >0, '#3BB97C', '#d9d9d9')};"/>

I really appreciate your help, I really do. Thank you so much.
Khan AnasKhan Anas (Salesforce Developers) 
Maybe you can try this:
 
<apex:outputText value="£{0, number, ###,###,###,##0.00}" >

Reference: http://www.infallibletechie.com/2013/10/how-to-set-currency-format-in.html


Regards,
Khan Anas
Matthew AllenMatthew Allen
great that worked, thank you. Now any ideas why it's ignoring the formatting in terms of Font size etc?
Khan AnasKhan Anas (Salesforce Developers) 
Not sure about the exact reason, but you can try to enclose it within pageBlockSectionItem probably.


Regards,
Khan Anas