function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Christian Juul MikkelsenChristian Juul Mikkelsen 

Date field with value null shows date today

I have a visualforce page and a controller.

In the controller I have a list of objects of wrapper class with a salesforce object as a variable. If the there is data in the wrapper class but not in the salesforce object (it is null), then the visualforce page shows the date of the salesforce object as date today (note that the variable is null).

I tried using an if statement i the apex outputfield but it is not allowed. So I had to use a outputText instead and use TEXT(object.datefield) but then the date is not formated which is not ideal.

Have any of you tried this?

I have noticed that there has been a similar issue before: https://success.salesforce.com/issues_view?id=a1p30000000T4O2AAK
Shashikant SharmaShashikant Sharma
Could you please share your code

Thanks
Christian Juul MikkelsenChristian Juul Mikkelsen
This is my wrapper class:
public class SubscriptionTopNodeWrapper implements Comparable{
		
	public string colorImageName {get; set;}
	public string topNodeSubscriptionName {get; set;}
	public string productName {get; set;}
	public Subscription__c subscriptionNode {get; set;}
	public list<SubscriptionChildNodeWrapper> childNodeSubscriptionList {get; set;}
	
	public Integer compareTo(Object objToCompare) {
		
		return productName.toUppercase().compareTo(((SubscriptionTopNodeWrapper)objToCompare).productName.toUpperCase());
		
	}
}

the code that adds the subscription to the wrappper class:
if(subscriptionWrapper.childNodeSubscriptionList != null && subscriptionWrapper.childNodeSubscriptionList.size() == 1)
{
	subscriptionWrapper.subscriptionNode = subscription;
}
The visualforce page:
<td>
	<apex:outputText value="{!IF(subscriptionWrapper.subscriptionNode=null, null, TEXT(subscriptionWrapper.subscriptionNode.License_Start__c))}" />
</td>
<td colspan="2">
	<apex:outputText value="{!IF(subscriptionWrapper.subscriptionNode=null, null, TEXT(subscriptionWrapper.subscriptionNode.License_Expiration__c))}"/>
</td>





 
Shashikant SharmaShashikant Sharma
May be you could use date formating like this 
<apex:outputText value="{0, date, MMMM d','  yyyy}">
    <apex:param value="{!NOW()}" />
</apex:outputText>
You could use other format if above does not work for you.