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
JVKJVK 

Problems with Visualforce IF logic

Hello,

I am trying to have a tab apear if the status of object project is ok (pickval).
I can't get it to work, I have looked everywhere

 <apex:tab label="Stem" name="Stem" id="tabStem" rendered= "{!IF ((Project__c.Status__c = "ok"),"True","False")}">

Error that is generated:
Error: Syntax error. Missing ')'

I am sure that the syntax is right. It also doesn't work if I do

<apex:tab label="Stem" name="Stem" id="tabStem" rendered= "{!IF (CONTAINS(Project__c.Status__c , "ok"),"True","False")}">

Anybody any ideas?
Thanks:smileyhappy:
Jeroen



dchasmandchasman
There are a few issues here:

1. rendered needs to be bound to a formula that returns a boolean value, e.g. true|false, not string values
2. the use of double quotes inside double quotes is not going to work - use single quotes to delimit strings just like you do in apex code
3 (possible issue) I suspect that Status__c is a custom picklist field and working with picklist data in formulas normally requires the use of the isPickVal() function (see the docs for more info on that).

Basically I would expect your rendered attributes to look more like this:

<apex:tab label="Stem" name="Stem" id="tabStem" rendered= "{!Project__c.Status__c == 'ok'}">

 

jeroenjeroen

Doug,

This is much simpler! It works like a charm. I looked everywhere but could not find anything explaining this!

Thanks very much:smileyvery-happy:

Regards

Jeroen

JackermanJackerman

Hi,

 

I am running into a problem that is similar to the one that you just answered, except that I am trying to have an InputField render if one of two picklists display the value 'Personal'

 

This is syntax as of now:

 

<apex:inputField value="{!account.Envelope_Personal__c}" rendered="{!account.Wealth_Beacon_Salutation__pc=='Personal'} || {!account.Holiday_Card_PL_Salutation__c=='Personal'}"/> 

 

Each of the fields render when I tested a formula with the each individually, so I think that it is my OR logic that is causing the problem.  Any incite on how to correct this?

 

Thanks!