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.

I have a custom numeric field: NumberOfOppsWon__c. I tried to put in some conditional logical in my email template based on its value being greater than zero.

<apex:outputPanel rendered="{!IF(relatedTo.NumberOfOppsWon__c > 0, true, false)}">
...
</apex:outputPanel>

When I try to save the email template, I get:

Error occurred trying to load the template for preview: The value 'null' is not valid for operator '>'.. Please try editing your markup to correct the problem.

Any ideas, tips?

share|improve this question
    
You may want to consider adding a default value for that field; zero sounds like it would make sense. –  Mike Chale Jan 2 '13 at 13:02

1 Answer 1

I think your NumberOfOppsWon__c field is pointing to null value and you can not compare a null with 0. you can compare like this -

<apex:outputPanel rendered="{!relatedTo.NumberOfOppsWon__c != null && 
relatedTo.NumberOfOppsWon__c > 0}">
...
</apex:outputPanel>
share|improve this answer
    
The IF-formula isn't really necessary if all it returns is true/false, rendered="{!relatedTo.NumberOfOppsWon__c != null && relatedTo.NumberOfOppsWon__c > 0}" should be enough. Readability is of course in the eye of the beholder, but to me that's easier to read as well. –  Martin Peters Jan 2 '13 at 13:03
    
Edited.... thanks –  Pramod Kumar Jan 2 '13 at 13:06
    
@Pramod Kumar tried setting default value. Getting same error. –  dublintech Jan 2 '13 at 13:17
    
@dublintech default value of an Integer is null thats why you are getting this error. Initialize it with 0. –  Pramod Kumar Jan 2 '13 at 13:20
    
@Pradmod Kumar Yes I did that. The default value is set to 0. And I get the same error. –  dublintech Jan 2 '13 at 13:29

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.