-1

I have an attribute which I want to pass to a visualforce component, how do I achieve this. Currently I get the error: expecting a boolean

Photoshoot="{!IF(!opportunity.Quote__r.Photoshoot__c!='','Photoshoot','')}"

Thanks in advance

1 Answer 1

2

A merge expression starts with {! and ends with }.
Inside the expression, you don't need to use {! any more to pull in properties from the controller, and ! is specifically the boolean "not" operator.

Evaluation generally happens left-to-right, and ! has pretty high precedence, higher than != does, so the first bit that gets evaluated is !opportunity.Quote__r.Photoshoot__c

If Photoshoot__c isn't a checkbox, then you won't be able to apply "not" to it. This explains the error you're getting.

I suspect this is just a simple mistake on your part. Getting rid of that stray ! should be enough to resolve the error, but I suspect you'll still have a semantic error.

From emperical testing, strings in SObjects don't store an empty string. Instead, they store null. Things can get a little more complicated if you have the string in memory though. In the end, the proper approach here is to use ISBLANK() instead of checking for an empty string (and null).

{!IF(NOT(ISBLANK(opportunity.Quote__r.Photoshoot__c)),'Photoshoot','')}

You must log in to answer this question.

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