You need to sign in to do that
Don't have an account?

How can i set date value to null when another date value is empty?
Am Selecting Contract Begining Date in a Visual Force Page

When I select Contract Begining Date populating Contract Ending Date

Now i would like show Contract Ending Date automatically empty when Contract Begining Date is empty

VF Page Code:
<apex:actionRegion >
<apex:inputField value="{!cont.Contract_Beginning_Date__c}" taborderhint="2" Style="margin-left:0.0%;" required="true" >
<apex:actionSupport event="onchange" action="{!AccAddress}" rerender="rty"/>
</apex:inputField>
</apex:actionRegion >
Apex Code:
Public void AccAddress()
{
if(cont.Contract_Beginning_Date__c!= null)
{
cont.Contract_Ending_Date__c = cont.Contract_Beginning_Date__c.addMonths(6);
}
if(cont.Contract_Beginning_Date__c == null)
{
cont.Contract_Ending_Date__c = null;
}
}
When I select Contract Begining Date populating Contract Ending Date
Now i would like show Contract Ending Date automatically empty when Contract Begining Date is empty
VF Page Code:
<apex:actionRegion >
<apex:inputField value="{!cont.Contract_Beginning_Date__c}" taborderhint="2" Style="margin-left:0.0%;" required="true" >
<apex:actionSupport event="onchange" action="{!AccAddress}" rerender="rty"/>
</apex:inputField>
</apex:actionRegion >
Apex Code:
Public void AccAddress()
{
if(cont.Contract_Beginning_Date__c!= null)
{
cont.Contract_Ending_Date__c = cont.Contract_Beginning_Date__c.addMonths(6);
}
if(cont.Contract_Beginning_Date__c == null)
{
cont.Contract_Ending_Date__c = null;
}
}
Your code looks good. Try to put debug statements in your code for begining and end date to check if it is entering the loop.
Best Regards,
Sandhya
Please give the complete code.