- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 05:36 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2016 06:52 AM
Soni,
Add alert in your call back function as shown below and let me know what you see.
Here is your onChange client script on Needed By variable:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setDisplay('title', false); // put in the variable name you want to show or hide according needed by date
return;
}
var ga = new GlideAjax('ValidateNeededBy');
ga.addParam('sysparm_name','validateDate');
ga.addParam('sysparm_needed_by',newValue);
ga.getXML(callBack);
function callBack(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(parseInt(answer)>=27){
g_form.setDisplay('title', false); // put in the variable name you want to show or hide according needed by date
}
else{
g_form.setDisplay('title', true); // put in the variable name you want to show or hide according needed by date
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 11:04 AM
Sure. I have a field called "Needed by" on a catalog item form as follows:
if the selected date is less than 3 business days , a field for justification is going to be shown, saying : needed by date is earlier than the required lead time, please supply justification:
for example if I select today , it is less than 3 business day , so that field should be shown

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 11:08 AM
Soni,
You will have to use GlideAjax for this. Give me the variable name of "Needed By", I will get back to you with the scripts. Your "Needed By" variable type is Date/Time right?
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 11:29 AM
Thanks a lot. the name is Needed_By and the type is date.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 12:11 PM
Soni,
Here is your onChange client script on Needed By variable:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setDisplay('title', false); // put in the variable name you want to show or hide according needed by date
return;
}
var ga = new GlideAjax('ValidateNeededBy');
ga.addParam('sysparm_name','validateDate');
ga.addParam('sysparm_needed_by',newValue);
ga.getXML(callBack);
function callBack(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if(parseInt(answer)>=27){
g_form.setDisplay('title', false); // put in the variable name you want to show or hide according needed by date
}
else{
g_form.setDisplay('title', true); // put in the variable name you want to show or hide according needed by date
}
}
}
Create a script include and name it as "ValidateNeededBy" only. Check the client callable checkbox and copy the following script as is.
script:
var ValidateNeededBy = Class.create();
ValidateNeededBy.prototype = Object.extendsObject(AbstractAjaxProcessor, {
validateDate: function(){
var dc = new DurationCalculator();
dc.setSchedule('08fcd0830a0a0b2600079f56b1adb9ae'); // this is the sys_id of 8-5 weekday schedule in your instance. You can put in the sys_id of the schedule you want to use
dc.setTimeZone('GMT');
var dur = dc.calcScheduleDuration(gs.now(),this.getParameter('sysparm_needed_by'))/3600;
return dur.toString();
},
type: 'ValidateNeededBy'
});
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2016 06:46 AM
Thank you so much Abhinay E , but unfortunately doesn't work!