Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

So I need to use an inline if statement in my visualforce page to decide whether or not I need to render an outputText. However I keep hitting a syntax error so I am hoping someone here will catch my (hopefully obvious) mistake.

So there is a field in my custom object that I want to print IF it is populated and not the Id of the contact page I am on. I am also iterating through a list of these objects. So here is what I wrote for an if statement

"{!IF({!relation.First_Contact__c} != null && {!relation.First_Contact__c} != contact.Id), true, false)"

again this is going in the rendered tag of an outputText so the returns are true or false. Also relation is the current custom object from the apex:repeat. Any help is MUCH appreciated.

share|improve this question
add comment

1 Answer 1

up vote 7 down vote accepted
"{!IF(AND(relation.First_Contact__c != null, relation.First_Contact__c != contact.Id), true, false)}"
share|improve this answer
    
Ah okay thank you very much! I thought the {! } would be necessary for the relation variable but since it is a visualforce variable and not an apex one I guess I don't. Thank you again! –  Louis Pujol Jun 16 at 21:35
    
@LouisPujol Could you 'accept' this, so it gets the green checkmark, greenstork gets the extra reputation points, and it's clearly marked as 'the answer'? Thanks! –  metadaddy Jun 16 at 21:47
    
@metadaddy Sorry he answered so fast I couldn't accept it immediately –  Louis Pujol Jun 16 at 21:48
    
Heh - no worries - thanks! –  metadaddy Jun 16 at 21:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.