You need to sign in to do that
Don't have an account?

apex variable problem in VF
I am setting the following variable to be reused in calculations
Below returns the error Error: Unknown property 'Cloud_Voice__cStandardController.monthly'
<apex:variable value="{!12}" var="term"/>
<apex:variable value="{!ROUND((Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000)/term),2)}" var="monthly"/>
<apex:variable value="{!monthly*term}" var="total"/>
Changing the term back to 12 works fine:
<apex:variable value="{!12}" var="term"/>
<apex:variable value="{!ROUND((Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000)/12),2)}" var="monthly"/>
<apex:variable value="{!monthly*term}" var="total"/>
Can't figure out why it does not work, any help?
Below returns the error Error: Unknown property 'Cloud_Voice__cStandardController.monthly'
<apex:variable value="{!12}" var="term"/>
<apex:variable value="{!ROUND((Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000)/term),2)}" var="monthly"/>
<apex:variable value="{!monthly*term}" var="total"/>
Changing the term back to 12 works fine:
<apex:variable value="{!12}" var="term"/>
<apex:variable value="{!ROUND((Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000)/12),2)}" var="monthly"/>
<apex:variable value="{!monthly*term}" var="total"/>
Can't figure out why it does not work, any help?
Looks like it is an issue with Round function, it does not accept apex:var as its parameters.
An alternate solution I can think of is, to split that into two variables as below
<apex:variable value="{!(Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000)/12)}" var="TEMPVAR"/>
<apex:variable value="{!ROUND(TEMPVAR,2)}" var="monthly"/>
Hope this helps!
***********************************
J G
Strangely while trying your suggestion i mistyped and found that it would appear to work for multiplication but not division so
<apex:variable value="{!ROUND((Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000) / term),2)}" var="monthly"/>
does not work, but
<apex:variable value="{!ROUND((Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000) * term),2)}" var="monthly"/>
does. Is this a bug?
It will not compile as the variable (even though set) is treated as possible null/0 which would then result in a divide by zero error.
This doesnt really make sense as you can use field that are null and compile, it simply results in a runtime error when the page is rendered.
Why is the behavious different from a set variable, who knows?