0

I am trying to use render if condition on a viasualforce based on a value containing a string but this seems not to work. What am I missing? See:

        <apex:pageBlock title="Manuals">
        <apex:pageBlockTable value="{!urlmap}" var="key">
            <apex:column value="{!key}"/>
            <apex:column width="150px">
                 <apex:outputtext rendered="{IF(CONTAINS({!key},'Manual'),true, false)}">
                <apex:outputLink value="{!urlmap[key]}">Click here to download</apex:outputLink>
                </apex:outputtext>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
1

Merge field is not required for variable already inside a merge fields, so the expression should go inside {! }:

<apex:outputtext rendered="{!IF(CONTAINS(key,'Manual'), true, false)}">
    <apex:outputLink value="{!urlmap[key]}">Click here to download</apex:outputLink>
</apex:outputtext>

You could get rid of IF as CONTAINS(key,'Manual') returns a Boolean already.

  • You missed ! in expression, I hope it was just a typo but thought it should be corrected. It would be {!IF(CONTAINS(key,'Manual'), true, false)} – Vijay Ganji May 23 at 9:09
  • Thanks @VijayGanji! – Raul May 23 at 9:11
  • @Raul Thanks. Must of had a typo I tried that in the past. – Thomas May 23 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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