1

I have an custom button on Lead object. That button should generate PDF document which i already made in visualforce. Sometimes when i click that button i get this message

"The value attribute on is not in a valid format. It must be a positive number, and of type Number, Date, Time, or Choice "

But sometimes it works perfectly. Also i have a lot of formating number fields in my table in that documents, and all of that fields i format like this:

<apex:outputText value="{0,number, ###,###,##0}">$<apex:param value="{!IF(lead.X401_IRA_Savings__c!=null,lead.X401_IRA_Savings__c,'N/A')}"/> 

Visualforce don't show me any error. I have also 1 field with Date value:

<apex:outputText value=" {0,date,MM/dd/yyyy }">    
<apex:param value="{!lead.createdDate}" /> 
</apex:outputText>

So i don't know what's the problem here, because i don't have any errors in visualforce and this is simple problem to do, and more weird is that, that sometimes work,sometimes not. Any help?

2 Answers 2

1

The expression in your outputText could be rewritten to:

<apex:outputText value="{0,number, $###,###,##0}" 
                 rendered="{!NOT(ISBLANK(lead.X401_IRA_Savings__c))}">
    <apex:param value="{!lead.X401_IRA_Savings__c}"/>
</apex:outputText>
<apex:outputText value="N/A" rendered="{!ISBLANK(lead.X401_IRA_Savings__c)}"/>
2
  • This is great, but i need N/A in that field if it is blanc... Dec 21, 2016 at 19:06
  • 1
    That's what I did. Using both blank and non blank rendered expressions. @IgorStosic
    – cropredy
    Dec 21, 2016 at 20:48
2

You have a conditional on lead.X401_IRA_Savings__c!=null. I can't tell if that's a decimal field, an integer field or a text field. If the latter, it could also be "blank" which could cause an issue with your PDF generating. Any fields along those lines that could be "blank" as opposed to null could cause a problem for you. !isEmpty() is the preferred method to use for that type of test per Salesforce recommendations. Depending on the type of field, it covers both isNull and isBlank.

The message is also saying the field in question needs to be a number, a boolean, a date or a time. That should tell you that it's likely you may have something which is a date-time field (or some other field type) that you've not converted to the correct format before trying to display it as text. It could be a simple case of having data that's not properly formatted causing your page to choke.

You must log in to answer this question.

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