- 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 07:08 AM
Soni,
As Mike suggested , use schedules for this. Then you could use duration calculator class to calculate days according to your schedule
Here is a sample script of it.
var dc = new DurationCalculator();
dc.setSchedule('4478d9d969bfa100f336d9fc410262ec'); //put in the sys_id of the schedule in your instance like 8-5 weekdays
var dur = dc.calcScheduleDuration(inc.end_time, gs.nowDateTime()); //calculate duration according to your schedule
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 09:49 AM
Actually I have a date field. if the selected date is less than 3 business days another field should be shown

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 10:40 AM
Soni,
here is your script for that. You can write this in a Business rule
Script:
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.nowDateTime(),put in the date time field you want to check)/3600;
if(dur>27){ //each working day is 9 hrs, so 3 working days is 9*3 27 hrs
gs.addInfoMessage("duartion is greater than 3 days");
}
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 10:50 AM
Thanks Abhinay E , but how am I able to write a business rule on a catalog item form?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 10:57 AM
Soni,
What exactly is your requirement? Can you please elaborate your requirement.
Thanks,
Abhinay