Restrict user to select date upto 3 months in Catalog item

ServiceNow SA
Kilo Guru

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.

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

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.


View solution in original post

9 REPLIES 9

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]

****************************************************************************************************************

Hi Jaspal,

 

The link is not opening the community article for me. Can you please reshare the link?

 

Thank you in advance!

Try this:

 

community.servicenow.com/community?id=community_question&sys_id=15658baddbd8dbc01dcaf3231f961936

Prateek kumar
Mega Sage

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

Prateek kumar
Mega Sage

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