- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 08:51 AM
We have a requirement to capture an effective date on a record producer and I have currently built a Date/Time variable that will allow us to do so. Now with that being said, the rest of the requirement is to prevent users from selecting a date/time in the past.
For example, today is 1/14/2016, therefore the user should NOT be able to select 1/10/2016 as a possible date.
Essentially, we want any date leading up to the current date/time to be read only. Is this a possibility and if so how do we go about it? I am not a programmer, so if there is a script involved, which I am positive there is, it would be much appreciated if you can help with that as well.
Thanks!
Niccole
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 11:22 AM
According to the SNow wiki article, the flash method is not supported by the Service Catalog. Thus that is prob why no matter what I am changing it to, it still is failing. Not a huge deal, it would have been nice to have the field flash a color, but the field is mandatory and clearing the value will force them to select a date before they can submit the request.
I very much appreciate all your help!
Here is the final script for anyone who is curious:
Catalog Client Script
Applies to: A Catalog Item
Type: onChange
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var dt = getDateFromFormat(newValue, g_user_date_time_format);
var rightNow = new Date();
if (dt < rightNow) {
alert('The date value cannot be before the current date and time. Please correct.');
g_form.clearValue("effective_date");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 09:54 AM
did you add the g_form at the start of that line?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 10:20 AM
Yep. This is the whole script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var dt = getDateFromFormat(newValue, g_user_date_time_format);
var rightNow = new Date();
if (dt < rightNow) {
alert('The date value cannot be before the current date and time. Please correct.');
g_form.clearValue(effective_date);
g_form.flash("effective_date", "#FFFF00", 5);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 10:22 AM
g_form.clearValue('effective_date');
i think you missed the ''
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 10:32 AM
So that worked for clearing the form, but the flash will not work.
I just tried
g_form.flash("effective_date", yellow, 2);
and that still didn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 11:22 AM
According to the SNow wiki article, the flash method is not supported by the Service Catalog. Thus that is prob why no matter what I am changing it to, it still is failing. Not a huge deal, it would have been nice to have the field flash a color, but the field is mandatory and clearing the value will force them to select a date before they can submit the request.
I very much appreciate all your help!
Here is the final script for anyone who is curious:
Catalog Client Script
Applies to: A Catalog Item
Type: onChange
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var dt = getDateFromFormat(newValue, g_user_date_time_format);
var rightNow = new Date();
if (dt < rightNow) {
alert('The date value cannot be before the current date and time. Please correct.');
g_form.clearValue("effective_date");
}
}