Planned start date cannot be earlier than current date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2023 08:00 AM
I have one requirement, Planned start date cannot be earlier than current date on release record.
I have written the below Onchange client script code, but i am getting the below script error. Please help me on this.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var devRelease = g_form.getDisplayValue('x_thntm_ntrs_devop_devops_release');
//alert('Dev Release :');
if (devRelease) {
var currentDate = new Date();
var startDate = new Date(g_form.getValue('start_date'));
if (startDate.valueOf() < currentDate.valueOf()) {
g_form.addErrorMessage('Error Message Planned start date cannot be earlier than current date');
g_form.setValue('start_date', oldValue);
return false;
}
}
Please find the below error message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2023 08:37 AM
I am getting the below error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2023 08:45 AM
Try removing .valueOf from both date objects, just use startdate < currentDate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2023 09:08 AM
I have removed .valueOf but no luck, if i removed this line 'g_form.setValue('start_date', oldValue);'
it is not getting the script error , but we need to set the old value as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2023 09:11 AM
@Suresh36 Did you check my script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2023 11:02 AM
Hi,
Can you try below code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var devRelease = g_form.getDisplayValue('x_thntm_ntrs_devop_devops_release');
if (devRelease) {
var currentDate = new Date();
var startDate = new Date(g_form.getValue('start_date'));
if (startDate.valueOf() < currentDate.valueOf()) {
g_form.addErrorMessage('Error Message: Planned start date cannot be earlier than current date');
g_form.setValue('start_date', oldValue);
return false;
}
}
}
Thanks,
Rahul Kumar
Thanks,
Rahul Kumar