1

I am having an issue storing the result of a simple math division of two local VFP variables into a third variable called Multiplier.

<apex:page readOnly="true"     
           standardController="NCQuote__c"
           showHeader="false"
           sidebar="False"
           applyBodyTag="false"
           applyHtmlTag="false">

<!-- SETTING CUSTOM OBJECT NAME  -->  
<apex:variable var="Obj" value="{!NCQuote__c}" />

<!-- CONFIDENTIAL PRICING CALCULATIONS  -->
<apex:variable var="Multiplier" value="{!0}" /> 
<apex:variable var="TotalNonConfidentialPrice" value="{!0}" />     
<apex:variable var="TotalLaborMaterialsSalesPrice" value="{!0}" />
<apex:variable var="C_RollupExtendedConfidentialPrice" value="{!0}" /> 
     
<apex:variable var="TotalLaborMaterialsSalesPrice" 
value="{!Obj.TotQAmt__c - Obj.TotalPlansSalesPrice__c}" />

<!-- C SPECIALTY ITEM LIST SIZE AND VALUES  --> 
<apex:repeat value="{!Obj.Specialty_Item_Relationship__r}" var="sir">
    <apex:variable var="C_RollupExtendedConfidentialPrice"
     value="{!IF(AND(sir.Excluded_Checkbox__c==FALSE,sir.Optional_Checkbox__c==FALSE,
            sir.Confidential_Checkbox__c==TRUE),sir.Extended_Confidential_Price__c + C_RollupExtendedConfidentialPrice,C_RollupExtendedConfidentialPrice)}"/>
</apex:repeat>

<!-- CALCULATING TOTAL NON-CONFIDENTIAL PRICE  -->     
<apex:variable var="TotalNonConfidentialPrice" value="{!TotalLaborMaterialsSalesPrice - C_RollupExtendedConfidentialPrice}"/>
    
<apex:variable var="Multiplier" value="{!TotalNonConfidentialPrice/TotalLaborMaterialsSalesPrice}"/> 

If I save the VFP, I get this error message: "Unknown property 'NCQuote__cStandardController.Multiplier'" Note that If I do any other math operations with the same variables (add, subtraction or multiplication), then I get no issue.

  • {!TotalNonConfidentialPrice + TotalLaborMaterialsSalesPrice} is OK

  • {!TotalNonConfidentialPrice - TotalLaborMaterialsSalesPrice} is OK

  • {!TotalNonConfidentialPrice + TotalLaborMaterialsSalesPrice} is OK

Even dividing the same variable on herself, it gives me an error {!TotalNonConfidentialPrice/TotalNonConfidentialPrice} gives me an error.

I must be missing something simple which I cannot figure out. Any help, it would be appreciated it.

2
  • PS. Checkboxes are already Boolean, you don't need to write sir.Excluded_Checkbox__c==FALSE, you can simply write !sir.Excluded_Checkbox__c or NOT(sir.Excluded_Checkbox__c) to check for false, and sir.Excluded_Checkbox__c for true.
    – sfdcfox
    Apr 25, 2022 at 23:47
  • @sfdcfox thank you very much! It makes sense. I thought that I was missing something. About the checkboxes, thank you for pointing it out. I should have done it the way you are suggesting.
    – cpaesano
    Apr 26, 2022 at 0:08

1 Answer 1

1

This is a Known Issue, and marked as No Fix, so I wouldn't wait on them fixing it. You can calculate the value either in Apex or JavaScript. You can still do division in the page if you want to use it for other purposes, you just can't divide in an assignment to an apex:variable and expect to use that variable elsewhere.

Summary

Fails to save VF page by "Error: Unknown property ..." when using division operator(/) with apex:variable and referring to the variable.

Repro

  • Steps to reproduce
  1. Try to save the following Visualforce page

<apex:page >
<apex:variable var="Test1" value="{!10}" />
<apex:variable var="Test2" value="{!5}" />
<apex:variable value="{!Test1/Test2}" var="Test3" />
{!Test3}
</apex:page>

You will see "Error: Unknown property 'Test3' referenced in ..." error. This is unexpected.


  1. Try to save the following Visualforce pages with */+/- operators.

<apex:page >
<apex:variable var="Test1" value="{!10}" />
<apex:variable var="Test2" value="{!5}" />
<apex:variable value="{!Test1*Test2}" var="Test3" />
{!Test3}
</apex:page>

<apex:page >
<apex:variable var="Test1" value="{!10}" />
<apex:variable var="Test2" value="{!5}" />
<apex:variable value="{!Test1-Test2}" var="Test3" />
{!Test3}
</apex:page>

<apex:page >
<apex:variable var="Test1" value="{!10}" />
<apex:variable var="Test2" value="{!5}" />
<apex:variable value="{!Test1+Test2}" var="Test3" />
{!Test3}
</apex:page>

You would be able to save the page successfully. These are working as expected.

Workaround

User can implement the method in their controller class for division operation instead of visual force page.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .