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
SrilakshmiSrilakshmi 

To display percentage and Currency field values on Visual force page.

Hi..

 

I have 2 fields on Account Object which are of data type Currency and Percentage.In my controller class method i need to calculate these values for some condition and store the value in some variable and display the variable value on VF page.

But, I am not able to declare a variable in controller class of  type percentage and Currency.

 

If i declare Double data type and store currency field values I will not be able to display in format for example  $2.8M

and  similarly I want to display percentage calculated in the format  76%.on the VF page

 

Can anyone please help me with this.

Edwin VijayEdwin Vijay

Did you try using

<apex:outputfield value="{fieldname}"/>

 

outputfield tag actually takes care of the formatting, whereas outputtext does not

 

SrilakshmiSrilakshmi

Hi but the value i am displaying is a variable value its not a Sobject field value so i cannot use outputfield.

Problem is I am able to display the variable value on the page but it is displaying like 54.6789.

 

I want to round off the value how can i do that please suggest.

mh218mh218

 

These posts helped me accomplish something similar:

 

Controller-Help-on-Calculating-Percentage

 

Displaying Rounded Percentages

 

I did some other work with rounding currency and percentages in visualforce last year - if I can find any of my notes/code samples I'll post.