How to validate planned start date and planned end date with Actual start and end date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2020 07:36 AM
Hi,
Could anybody suggest me to put validation for planned start date, planned end date and actual start date, actual end date fields.
Actual start and end date field will allow to submit the value in between planned start and end date.
How to put validation for user to submit the values in actual start and end date based on date range selected for planned start and end time.
Example:
Planned start - 20/10/2020
Planned end - 24/10/2020
Actual start - 21/10/2020
Actual end - 24/10/2020
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2020 07:54 AM
Hi Gayathri,
Find the below link that will help you for date validation.
https://community.servicenow.com/community?id=community_question&sys_id=7a4c5c2adbca13042328f3231f9619c6
https://community.servicenow.com/community?id=community_question&sys_id=4fca876ddb5cdbc01dcaf3231f961999
Let me know if it is useful.
Regards,
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2020 08:37 AM
Hi Gayathri,
You can use Before Business Rules -- Insert/Update
Conditions:
Actions: Abort ---> add Message
OR
If you want to use Client Script:
1) onChange --> actual start date:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '')
return;
var showErrorMsg = function(errorMsg){
g_form.showErrorBox("work_start", errorMsg);
};
g_form.hideFieldMsg("work_start", true);
if (validateStartDateBeforeEndDate("start_date", "work_start", showErrorMsg) && (typeof validateMaxDateDuration !== "undefined"))
validateMaxDateDuration("start_date", "work_start", showErrorMsg);
}
2) on Change --> actual end date:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '')
return;
var startDate = g_form.getValue("work_end");
var endDate = g_form.getValue("end_date");
var format = g_user_date_time_format;
if (startDate === "" || endDate === "")
return true;
var startDateMs = getDateFromFormat(startDate, format);
var endDateMs = getDateFromFormat(endDate, format);
if (startDateMs > endDateMs) {
g_form.showErrorBox('work_end', new GwtMessage().getMessage("{0} cannot be after {1}", g_form.getLabelOf("work_end"), g_form.getLabelOf("end_date")));
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2020 06:16 AM
Hi Gayathri,
Hope you are doing good.
Let us know if you question has been answered.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.