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
shan876shan876 

<apex:outputField>????

What is wrong with my statement:

  Also All I want to do is drop the CurrencyISO from the field:

<apex:outputField value="{!SUBSTITUTE(TEXT(ROUND(item.Unit_Price__c, 0)), "GBP", "," )}" />

 

 

Best Answer chosen by Admin (Salesforce Developers) 
SteveAnderson41SteveAnderson41

I can't teach you how to use controller extensions and Apex in a forum post.  Take a look at the Visualforce Dev Guide section on Custom Controllers.   Then spend some time reading the Apex Dev Guide.

 

If you really spend some time learning how Visualforce and Apex work together, it will make it easy for you to solve a lot of the questions you have been asking, but if you jump in without really understanding it, you'll confuse yourself more, rather than solving your problems, so don't rush; take your time to understand.

 

Most likely you'll find that you can use the methods on the Apex decimal type to do everything you need in a very simple controller.  For example, setScale() allows you to return a number with two decimal places.

 

Apex is really, really powerful.  I'm sure you'll find it worth the time investment to learn how to use it with Visualforce.

All Answers

JimRaeJimRae

I believe that outputfield is expecting a salesforce object field as its value.

try using outputtext instead.

SteveAnderson41SteveAnderson41

This is the way to use the formula you posted:

 

<apex:outputText value="{0}">
<apex:param
value="{!SUBSTITUTE(TEXT(ROUND(item.amount, 0)), 'GBP', ',' )}"/>
</apex:outputText>

 

It doesn't do what you want, though, since it doesn't include the values after the decimal if it's 00 or 0#.    Try something like this instead:

 

 

<apex:outputText value="{0}.{1}">
<apex:param value="{!SUBSTITUTE(TEXT(FLOOR(item.amount)), 'GBP', ',' )}"/>
<apex:param value="{!RIGHT(TEXT(ROUND((item.amount * 100), 2)),2)}"/>
</apex:outputText>

 

I don't think you really want to do this, though, since you lose the currency indicator for the field, and that can be important.

 

For example, if you have two opportunities, one is using GBP and the other is using USD,the first opportunity will display the value in GBP and the second in USD, but the user won't know that.

shan876shan876

yes you are correct.. But the client wants the currency to be up on top of the pageblock... but also, wants the number to be formatted as 0,00.00

I could not get it to work that way... it kept coming up as 000.0

Thanks

Shan

shan876shan876

Would you happen to know from your method up on top ... to place the comma in there...

like instead of 1965.95 have it say 1,965.95

Thanks

SteveAnderson41SteveAnderson41
With all of these special cases, I think you probably want to move your logic into Apex.  You can probably use a controller extension that allows you to use the logic in multiple places and pages, rather than having to repeat the various formulas in each place.
shan876shan876

would you have an example of that? please

thanks

shan

SteveAnderson41SteveAnderson41

I can't teach you how to use controller extensions and Apex in a forum post.  Take a look at the Visualforce Dev Guide section on Custom Controllers.   Then spend some time reading the Apex Dev Guide.

 

If you really spend some time learning how Visualforce and Apex work together, it will make it easy for you to solve a lot of the questions you have been asking, but if you jump in without really understanding it, you'll confuse yourself more, rather than solving your problems, so don't rush; take your time to understand.

 

Most likely you'll find that you can use the methods on the Apex decimal type to do everything you need in a very simple controller.  For example, setScale() allows you to return a number with two decimal places.

 

Apex is really, really powerful.  I'm sure you'll find it worth the time investment to learn how to use it with Visualforce.

This was selected as the best answer
UmapenUmapen

I have written a custom controller, to do some caclulation and the result is coming as double.

In my apex page I am using the following line to display value

         <apex:column headerValue="Distance" value="{!aAcct.Distance}"/>

I do not know how to format this. Apex pages shows  big number. "25.77704809822828"

 How can I use LEN function to show  25.77 only?

 

Thanks