- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2018 03:54 PM
Hi,
i have BR script , it is working fine , there is no problem with BR script, i would like to see this functionality in client script
CLIENT SCRIPT -ONCHANGE
BR script: how can i write it into Client Script
var today= new GlideDateTime();
var past=new GlideDateTime(current.u_review_date);
var todaydate=today.getLocalDate();
var pastdate=past.getLocalDate();
if(pastdate.before(todaydate))
{
gs.addInfoMessage("Please don't select past date");
current.u_sunset_review_date="NULL";
current.setAbortAction(true);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2018 02:28 AM
You can follow below link, using Script Include and Client script will resolve your issue.
https://community.servicenow.com/community?id=community_question&sys_id=abd88f61db5cdbc01dcaf3231f9619f5
Thanks
Shashikant
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2018 02:04 AM
Hi Chanikya,
Any updates on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2022 06:11 AM
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ajax = new GlideAjax('PlannedDateTimeAjax');
ajax.addParam('sysparm_name', 'nowDateTime');
ajax.getXML(checkdate);
function checkdate(response) {
var currentDate = response.responseXML.documentElement.getAttribute("answer");
var startDate = g_form.getValue('start_date');
if (startDate < currentDate) {
g_form.showFieldMsg('start_date', 'Start date cannot be in the past', 'error');
}
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2022 06:11 AM
Not working with Return false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2018 02:28 AM
You can follow below link, using Script Include and Client script will resolve your issue.
https://community.servicenow.com/community?id=community_question&sys_id=abd88f61db5cdbc01dcaf3231f9619f5
Thanks
Shashikant
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2018 02:56 AM
Hi,
Thanks for your replay,
is it possible to set Date value without using SCRIPT INCLUDE,
client ONCHANGE: By using this ,
var now = new Date();
now = formatDate(now, g_user_date_time_format);
now = getDateFromFormat(now, g_user_date_time_format);
var X = g_form.getValue('review_date'); //Review date is field on the form.
X = getDateFromFormat(X, g_user_date_time_format);
if (X < now) {
alert('Selected date is in the past.');
g_form.setValue('review_date', '');
}
return false;
}