0

I've isolated a syntax error down to one simple addition of an inline IF function.

If I comment out Block B and uncomment A, it compiles fine and renders as expected. If all I do is comment out Block A and uncomment Block B, Mavensmate won't let me compile and throws this error:

Result: [COMPILE FAILED]: (RevenueSchedule) Syntax error.  Missing ')'  (Line: 1, Column: -1)

Block A:

<apex:inputText id="revAmt" 
rendered="{!IF(isLocked == false,'true','false')}" 
value="{!sched.revenue}" 
styleClass="amountField" 
onchange="updateTotals('{!revSched.lineItem.id}');" />

Block B:

<apex:inputText id="revAmt" 
rendered="{!IF(isLocked == false,'true','false')}" 
value="{!IF(revSched.scheduleType == 'L',revSched.totalRevenue,sched.revenue)}" 
styleClass="amountField" 
onchange="updateTotals('{!revSched.lineItem.id}');" />

As you can see, they are identical besides the addition of the IF function to block B. That's the only reason I haven't definitively concluded that the syntax error lies elsewhere on the page. Can anyone see anything definitely wrong syntactically with anything in Block B, or any reason Block A would compile but not B?

3
  • 1
    as an aside, why are you not using {!IF(NOT(isLocked),true,false)}; also I use = in formulas in lieu of == as merge field formulas don;t follow apex rules
    – cropredy
    Commented Apr 21, 2015 at 17:03
  • I'm the fourth out of four developers to work on this, most of this was existing code Commented Apr 21, 2015 at 17:21
  • many sympathies - is RevenueSchedule the name of the VF page? Sometimes I end up successively commenting out portions of the page in order to look for the issue; if you think this is MavensMate and not the VF compiler, try compiling in Developer Console
    – cropredy
    Commented Apr 21, 2015 at 17:25

1 Answer 1

2

This works with an output field, but not an input field. The value parameter cannot conditionally bind to two different fields.

<apex:page showHeader="true" sidebar="true" standardController="Account">
    <apex:form>
        <apex:inputText value="{!IF(FIND(Account.Name, 'a') >= 0, Account.Name, Account.AccountNumber)}"/>
    </apex:form>
</apex:page>

This does not compile, but change inputText to outputText and it will work.

To make this work, you will need to move that logic into your controller.

Set up a conditional getter and a conditional setter to set/get the value of either sched.revenue or revSched.totalRevenue depending on the logic you want.

You must log in to answer this question.

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