- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 07:18 AM
Hi Team,
I have a date field in my catalog item. I need user to select dates only upto 3 months from now.
For eg, If user is raising request today , he should only be able to select date till 21-Feb-2018 .Not more than that.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 07:21 AM
Hi Sri,
Link Limit date selection in date field has a UI policy part for limiting date selection possibly that would help & would be simplest one to set up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2024 03:48 AM
You can do via UI policy aslo.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2024 10:40 PM
Hi Jaspal,
The link is not opening the community article for me. Can you please reshare the link?
Thank you in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2024 08:18 AM
Try this:
community.servicenow.com/community?id=community_question&sys_id=15658baddbd8dbc01dcaf3231f961936
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 07:21 AM
This post should help you
Client Script Date/Time Functions
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 07:54 AM
Hello Sri
Try this:
SI:
Client callable: checked
Name:DateValidation
DateValidation.prototype = Object.extendsObject(AbstractAjaxProcessor, {
validateDate: function() {
var ActualEndDate = this.getParameter('sysparm_end_date');
return gs.dateDiff(gs.now(),ActualEndDate, true)/(86400*90); //90days
},
type: 'DateValidation'
});
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
alert('on change started');
var ga = new GlideAjax('DateValidation');
ga.addParam('sysparm_name','validateDate');
ga.addParam('sysparm_end_date',g_form.getValue('u_new_date')); //give your field name to be validated
ga.getXML(ProcessResult);
function ProcessResult(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if (answer > 1)
{
g_form.clearValue('u_new_date'); //give your field name to be validated
alert('End Date should not be in the Past 90 days.');
}
}
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks