exception: org.mozilla.javascript.EvaluatorException: Can't find method com.glide.schedules.Schedule.add(java.lang.String,com.glide.glideobject.GlideDuration). (sys_script.53ab4990136c238048fb58222244b04d.script; line 45)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 05:31 AM
Hi,
I am using the GlideSchedule API to calculate due date for incident using the incident opened date and a duration. My code looks like below:
var openedAtDate = current.opened_at.getDisplayValue(); //String type date
var gdt = new GlideDateTime();
gdt.setDisplayValue(openedAtDate);
var dateTime = gdt.getDisplayValue(); //Object type date
//This is used as duration
var dueDays = 1;
var dueHours = 16;
var dueSeconds = dueDays * dueHours * 60 * 60;
var leadTime = new GlideDuration(dueSeconds*1000);
var dueDateGdt;
var schedRec = new GlideRecord('cmn_schedule');
if (schedRec.get('name', myScheduleName)){
var sched = new GlideSchedule(schedRec.sys_id);
dueDateGdt = sched.add(dateTime, leadTime);
}
Here dateTime & leadTime are both of type object.
I am executing this in a business rule when an incident is created.
When I create an incident I get below error message:
Error running business rule 'Set Due Date for P5' on incident:INC0829815, exception: org.mozilla.javascript.EvaluatorException: Can't find method com.glide.schedules.Schedule.add(java.lang.String,com.glide.glideobject.GlideDuration). (sys_script.53ab4990136c238048fb58222244b04d.script; line 45)
This business rule belongs to Global application.
As per below reference, GlideSchedule is for scoped apps and since I am using it in Global application, I get the error 'Schedule.add is not found'.
https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/GlideScheduleScoped/concept/c_GlideScheduleScopedAPI.html
I would like to calculate the due date using the schedule defined in cmn_schedule table. Is there an alternative to this for calculating a due date?
Please note: I do not want to use SLA for incident.
Thanks,
Tanmay
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 06:29 AM
I don't see variable for myScheduleName
if (schedRec.get('name', myScheduleName)){
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 06:35 AM
Looks like I missed that when copying my code. It is:
var myScheduleName = 'HRI 8AM -5PM Weekdays Europe/Rome';