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
MigMig 

Currency Format :

I've got this code :

Code:
var qry = "select q.Price__c from Quotes__c q where q.Id='"+ varID +"'" ;
var result = sforce.connection.query(qry);
resultarray = result.getArray('records');

alert(" PRICE: " + resultarray[0].Price__c ); 

The result of the alert is : PRICE : 567.6789

Although I would like to have this quind of format : EUR 567,68 or USD 567.68
It depends on the user ....

I've got the same problem with the date formats I've got all them in this format YYYY-MM-DD And Ofcourse it should depends on the user who is calling my S-control page . 

PLEASE HELP ME =)

Thank you







Message Edited by Mig on 06-13-2008 10:54 AM
Greg HGreg H
You can utilize information related to the user to handle the formatting.  Use the following script to get the information I am referring too:
Code:
var user = sforce.connection.getUserInfo();

Your variable "user" will now contain information you can utilize such as userDefaultCurrencyIsoCode, userLanguage, userLocale & currencySymbol. Simply alert the variable to see all options and formatting of results.
 
It will likely require some arrays to lookup variations in currency formatting and date formatting based on the country or location but this information should help get you started.
-greg
MigMig
Ok. thankx for your answer

So There is noway to capture the values with the exact look the user have ... That's really a shame !! :(
Offcourse I can do it with the parent object :

'{!Quote__c.Quote_Date__c}'; // This will show in the S-Control the right date format of the user ...

But It's impossible to catch out the Quote Lines fate formats with an S-Control triggered by a Quote detail page button  ... 
 
I've got too much differents users in different countries in my org to filter them all with different formats and create different code .... wow :S

Anyway .. Tkx a lot for your answer .. if someone else has other solution it will be great ...
 
Mi


 


Message Edited by Mig on 06-16-2008 10:51 AM
mtbclimbermtbclimber
Not in scontrols without writing your own formatting functions in javascript that are aware of the user's locale, the currency formatting rules (# of decimal places, etc) and the currency type.

Of course there is another alternative - Visualforce .

The code for a visualforce page that shows opportunity date and amount (in a multi-currency org) as the user would otherwise see it in the standard page follows:

Code:
<apex:page standardController="Opportunity">
    <apex:pageBlock title="Opportunity Fields">
        <apex:pageBlockSection >
            <apex:outputField value="{!opportunity.closedate}"/>
            <apex:outputField value="{!opportunity.amount}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

 
Yes, that's it.

The Visualforce component outputField does all the formatting automatically.

The output of that markup plus the markup itself in the "Development Mode Footer" which allows you to edit Visualforce pages "inline" in the application follows after my signature.

Regards,
MigMig
Thanks a lot for your answer. It's very clear now !
I should do it in Visualforce (with the Print to functionnality)  instead of an S-Control. I will try that for the next relase of my application. =)

Anyway Thankx one more time to both of you for the time you spend answer my question.

Cheers,
Mig