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
Indu Prasad 26Indu Prasad 26 

Currency field in backend displays as string when used in Apex

I have a currency field on a custom object. In the object detail, the field displays properly as a currency field with the currency symbol and commas. However, I am using this field in Apex to display a table. I get only the number and no comma separators for them.

Current Line of code:
row1+='<td style="text-align:center">'+ '$' + Object__c.Revenue__c+'</td>';

If revenue is like 10000, I want it to display as 10,000. This is not happening. What can be done to rectify this issue?
Vishwajeet kumarVishwajeet kumar
Hello,
You should either format the field data in required format or use apex:outputField (In Visualforce page) for field data display which should auto format it.

Thanks