- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2024 06:17 AM
Hi Community,
there are two date fields
there should not be gap between them greater than two years, if it is, then alert message should pop up in the record.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2024 06:23 AM
Hi @rah dev, you can try following client script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2024 06:23 AM
Hi @rah dev, you can try following client script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2024 06:34 AM
Hi Rah,
You will need a client script and a script include to do what you need. The client script will be either just that or a catalog client script, depending on the context. The script include must be client callable. Your client script will issue an AJAX call to the script include, passing the two date values as strings. The script include will instantiate two GlideDateTime variables from the passed parameters. From there you have any of several ways to do the comparison, perhaps something like this:
var theStart = new GlideDateTime(sysparm_start);
var theEnd = new GLideDateTime(sysparm__end);
theStart.addYears(2);
var theDif = theStart.compareTo(theEnd);
if (theDif >= 0) {
return true;
}
return false;
:{)
Helpful and Correct tags are appreciated and help others to find information faster