I need to add a special character for a field on VF page and it's throwing an exception.

Error: Incorrect parameter type for operator '+'. Expected Text, received Number

Can anyone help me with this, please?

<apex:outputText value="{! IF( ISBLANK(Quote.Total_Leasing_Costs__c), '-', '$'+Round(Quote.Total_Leasing_Costs__c,0)) }"/>+
  • Have you tried using the TEXT() function to convert the round value to text? Also you have a plus sign at the end of the line, is that in your code? Jun 13 '19 at 19:27

Wrapping the ROUND() output within a TEXT() is what you need here. + in this context expects appending two string values whereas ROUND() returns a number and thus the error.

<apex:outputText value="{!IF(ISBLANK(Quote.Total_Leasing_Costs__c), '-', 
                        '$' + TEXT(Round(Quote.Total_Leasing_Costs__c,0)))}"/>
  • It worked, thank you for your help.
    – Abby
    Jun 13 '19 at 19:51
  • Glad that it worked and that I was able to help.
    – Jayant Das
    Jun 13 '19 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.