- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2018 11:42 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 12:42 AM
Hi chanikya,
There looks to be a few errors in your code. I have redone both the Script Include and the Catalog Client Script below. Note these are just done by hand and have not been tested with a Catalog Item.
Script Include:
var ScheduleUtils = Class.create();
ScheduleUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
inUserSchedule: function() {
var date = this.getParameter('sysparm_date');
var startDate = new GlideDateTime(date);
var inSchedule = false;
var employee = this.getParameter('sysparm_emp');
var user = new GlideRecord('sys_user');
if(user.get(employee)) {
var schedule = new GlideSchedule(user.getValue('schedule'));
inSchedule = schedule.isInSchedule(startDate);
}
return inSchedule;
},
type: 'ScheduleUtils'
});
Catalog Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var date = g_form.getValue('date');
var user = g_form.getValue('u_user');
var scheduleUtils = new GlideAjax('global.ScheduleUtils');
scheduleUtils.addParam('sysparm_name', 'inUserSchedule');
scheduleUtils.addParam('sysparm_date', date);
scheduleUtils.addParam('sysparm_emp', user);
scheduleUtils.getXMLAnswer(function(answer) {
if(answer == false) {
g_form.clearValue('u_hours');
} else {
g_form.showErrorBox('date', 'Is in schedule');
g_form.setValue('u_hours', 4);
}
});
}
Hopefully the above will be enough for you to resolve your issue! Can you also double check the names of the variables on your form? the u_ prefix normally exists on user created tables and fields however it is not automatically added on catalog variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 12:52 AM
it is working here displaying hours, but problem is - if i am taking Sunday, saturdays, holidays dates then also it is displaying hours. need to exclude Holidays, sundays, saturdays dates,
if i select Holidays, sundays, saturdays clear hours feild value
Can you suggest me to fix it

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 01:40 AM
Hi Chanikya,
What is the schedule set on the account you are testing with? As per the Product Documentation on GlideSchedule the isInSchedule() method of the GlideSchedule API determines if the datetime that is passed in occurs within the specified schedule. if you want to exclude holidays and weekends you will need to setup a schedule that excludes them. Out of the box there is a 8-5 weekdays excluding holidays schedule that you can reference and copy then modify to suit your purposes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 02:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 02:58 AM
Can i expect any updates please

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 03:18 AM
Hi Chanikya,
It is almost bed time for me in my part of the world so I am going to have to leave this one until tomorrow. You should have everything you need to resolve this issue. For your next step, I would suggest some debugging in the script include to determine if the value being compared against is as expected and that the comparison itself is working as expected. As I mentioned before I made those scripts for you quickly in the community here to help you get started so they were untested but should be working / or at least very close.
Best of luck! If this is still unresolved tomorrow I will try to assist you further.