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
Durai SaravananDurai Saravanan 

Date field values restricting.

Hi,

Good day!
I have two custom objects, Project__c and Milestone__c,
Here, Milestone__c is having Lookup to Project__c. [Every project will have several milestone]
Project_c has two date fields(start_date__c , end_date__c)
Milestone__c has two date fields(start_date__c , end_date__c)

So, When i create a milestone, I select the project__c to which this milestone is going to be part of. And this milestone's duration should be within the start_date__c and end_date__c of the project__c it is belonging to. 

Is there any way to restrict the values displayed in start_date__c and end_date__c fields of the milestone__c, to be within the duration of project it is belonging to.


Thanks in advance,
Durairaj Saravanan.
Aleksei KosovAleksei Kosov
I think you need to use a validation rule. This will be the most optimal and fastest option.
SandhyaSandhya (Salesforce Developers) 
Hi,

You can create validation rule on child object with the condition
if(milestonedate >= projectstartDate && milestonedate <= projectendDate);

Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
Durai SaravananDurai Saravanan
Yes, Thanks for the solution, But apart from Validation rules, Is there any way to restrict the start date and end date of milestone, based on the parent project's Start date and end date?