2

I have an apex:inputText and I'm trying to set the initial value which the user can edit. It's a simple IF formula but it keeps giving me the error:

Syntax error. Missing ')'

Here's the line (when I remove it the error goes away):

<apex:inputText id="daysToCount" style="width: 30px;" value="{!IF(prefs != null && prefs.Recent_Interaction_Days__c != null, TEXT(prefs.Recent_Interaction_Days__c), '30')}"/>

What am I doing wrong?

2 Answers 2

1

Update

Move your binary operators into a 'rendered' attribute to determine which type of input you want to show, than flip the variables accordingly:

<apex:inputText id="daysToCount" style="width: 30px;" value=" TEXT(prefs.Recent_Interaction_Days__c)}" rendered="{!IF(prefs != null && prefs.Recent_Interaction_Days__c != null)}"/>
<apex:inputText id="daysToCount" style="width: 30px;" value="30" rendered="{!IF(prefs != null && prefs.Recent_Interaction_Days__c == null)}"/>
6
  • Jordan: I think you have the parentheses around the first part wrong; wouldn't IF(prefs!=null) end the IF statement?
    – Mike Chale
    Oct 9, 2012 at 16:55
  • Your right, I reworked my answer. Oct 9, 2012 at 17:01
  • I think maybe I'm getting confused here. I don't want to bind the inputText variable on submit. I just want to show either Recent_Interaction_Days__c or 30 depending on whether Recent_Interaction_Days__c has a value. The user can then edit this value as they please. I thought I could do this with IF[true/false condition: prefs != null && prefs.Recent_Interaction_Days__c != null][if true:TEXT(prefs.Recent_Interaction_Days__c)][if false:'30']
    – George S.
    Oct 9, 2012 at 17:22
  • Oh my bad I thought you were working these binary operators for an 'rendered' attribute! Not 'value' - will try to rework my answer now. Oct 9, 2012 at 17:33
  • 1
    If you have custom controller try the logic in controller itself.Thats the best practice Oct 9, 2012 at 17:34
2

Just a heads up, I got the same error when attempting to put a function into the value attribute of the apex:column element. That is not allowed, and instead you should put the function into the value attribute of the apex:column's parameter:

<!-- WRONG -->
<apex:column value="{!RIGHT(line.name, 5)}"/>

<!-- RIGHT -->
<apex:column>
  <apex:outputText value="{!RIGHT(line.name, 5)}"/>
</apex:column>

You must log in to answer this question.

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