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
Raghavendra M 13Raghavendra M 13 

How can i set date value to null when another date value is empty?

Am Selecting Contract Begining Date in a Visual Force Page
User-added image
When I select Contract Begining Date populating Contract Ending Date
User-added image
Now i would like show Contract Ending Date automatically empty when Contract Begining Date is empty
User-added image
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;             
        }
    }    
SandhyaSandhya (Salesforce Developers) 
Hi,

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
PINKY REGHUPINKY REGHU
Hi,
     Please give the complete code.