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
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityA 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','')}