I want to display a button but only when two fields are matched (Category__c = Events & Custom_URL__c IS NOT BLANK).

<apex:outputLink value="/register" id="register" rendered="{!IF(AND(article.Category__c == 'Events', NOT(ISBLANK(article.Custom_URL__c))), TRUE, FALSE)}">

But on items where Custom_URL__c is populated (with a URL) the link is still not shown.

I have done SOQL query to see what data is being recieved and the Custom_URL__c field is clearly populated in the record.

  • Have you tried reducing your condition to {!NOT(ISBLANK(article.Custom_URL__c)} to verify that it is just the URL part that is the issue? – BarCotter Jan 27 '15 at 10:50
  • I have yes, it is still not working – Deployment Failure Jan 27 '15 at 10:52
  • 1
    Add an apex:outputText element to test out your formula. Start with a simple output such as <apex:outputText value="{!article.Custom_URL__c)"/> or <apex:outputText value="{!'URL:' & article.Custom_URL__c)"/> and then keep adding to it each time to verify the output is as expected. – BarCotter Jan 27 '15 at 10:59
  • The field was not shown, this leads me to believe the field is not visible under the current profile. – Deployment Failure Jan 27 '15 at 11:21
  • That would cause that type of problem alright. – BarCotter Jan 27 '15 at 11:22

The best way to debug these types of issues is too start with the simplest formula/condition and display it in an apex:outputText element. In your case you could start off with:

<apex:outputText value="{!article.Custom_URL__c)"/>
// OR this
<apex:outputText value="{!'URL:' & article.Custom_URL__c)"/>

You can then verify that the output is as you expected. Then add more and more to the formula, while checking the output as you go along.

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.