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
Chris ConfortiChris Conforti 

Visualforce: OutputText needed to calculate two fields

Hello;
I am building a visualforce page that will be used as a button on a custom object.
I have it all built with one hiccup, I need to calculate the sum value of two fields;

Field 1: "Check Fee" datatype is formula (text) with following formula;
CASE(Location_State__c, 
"CT", "$20", 
"NY", "$20", 
"$25")

Field 2: "Check Value" is datatype currency without forumla
User will input this value during the record creation

The purpose of the Apex:OutputText is to take the formula field and add that to the currency field creating a SUM value.

Below is the code I am using, along with the returned error
<apex:outputField value="{!Returned_Checks__c.Check_Fee__c + Returned_Checks__c.Check_Value__c}" /></b></u>
Error: Incorrect parameter type for operator '+'. Expected Text, received Object

..Any help is appreciated!


Chris C.
ManojjenaManojjena
Hi Cris,
If you will change the return type of your formula to Currency it will work .


 
Chris ConfortiChris Conforti
Hello Manoj;
Thank you for replying.
I had tried your suggestion earlier, however; since I am using a Case formula with field 1, changing the return type from text to currency will not work.  I receive the below error;

Error: Invalid Data. 
Review all error messages below to correct your data.
Formula result is data type (Text), incompatible with expected data type (Currency). (Related field: Formula)
  

Any Thoughts?

Chris C.