compare two date fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2016 04:06 AM
i have two date fields
1)start date
2)end date
if start date is greater than end date,abort the form from submission
please help me with the businees rule script..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2016 04:20 AM
var result = gs.dateDiff (current.start_date, current.end_date, true);
if(result < 0 )
current.setAbortAction(true);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 02:39 AM
Did The Trick!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2016 04:44 AM
function onSubmit()
{
var edt = g_form.getValue('u_end_date');
var sdt = g_form.getValue('u_start_date')
if(edt < sdt)
{
alert("Please enter date that is more value than current date");
return false;
}
else
{
alert("U entered correct date");
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 09:30 AM
Please help me
https://community.servicenow.com/community?id=community_question&sys_id=aa6f9ebb1b23d810d2ccea89bd4bcbef
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2016 05:18 AM
HI Prashanth,
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var toDate = g_form.getValue('u_to_date');
if(toDate==null || toDate==''){
g_form.addErrorMessage('Please select the Date first');
return;
}
else{
var fromDate = new Date(newValue);
var to_Date = new Date(toDate);
if(fromDate>to_Date){
g_form.addErrorMessage("to date should be greater than from date plz select from date should be less than to date");
g_form.setValue('u_from_date',oldValue);
return;
}else{
g_form.clearMessages();
}
}
}
try with as tiz with your field names:::
Thanks,
Dasthagiri K
PS: Hit like, Helpful or Correct depending on the impact of the response.