What is the workaroud for thisMap.addInclude when using in scoped applications?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2024 10:02 PM
the following script works in globla application
when iam trying the same in our one of the scoped application iam receiving the below error
ERROR: Function addInclude is not allowed in scope (my scope name)
var session = gs.getSession(); var timeZone = session.getTimeZoneName(); var scheduleGUID = 'caa944c2db7a3b40746bc4048a9619ff'; //one specific maintenance schedule var daysAhead = 21; gs.log('Session timezone is: ' + timeZone); var schedule = new GlideSchedule(scheduleGUID); schedule.setTimeZone(timeZone); gs.log('Schedule is: ' + schedule.name.toString()); // Start from Today var gd = new GlideDate(); var gdt = new GlideDateTime(); gdt.setNumericValue(gd.getNumericValue()); // GDT (GlideDateTime) // Start Date var sd = new GlideDateTime(); sd.setValue(gdt.getDate() + " 00:00:00"); // End Date var ed = new GlideDateTime(); ed.setValue(gdt.getDate() + " 23:59:59"); ed.addDaysUTC(daysAhead); // SDT (GlideScheduleDateTime) // Start Date var ssd = new GlideScheduleDateTime(sd); // Start Day ssd.setTimeZone(timeZone); // End Date var sed = new GlideScheduleDateTime(ed); // End Day sed.setTimeZone(timeZone); // Get Where Schedule Entries overlap with your Start/End Dates var scheduleMap = schedule.getTimeMap(sd, ed, timeZone); var span = new GlideScheduleDateTimeSpan(ssd, sed); var thisMap = new GlideScheduleTimeMap(); thisMap.addInclude(span); thisMap.buildMap(timeZone); overlaps = scheduleMap.overlapsWith(thisMap, timeZone); overlaps.buildMap(timeZone); gs.log('Getting spans from now and the next ' + daysAhead + ' days.'); while (overlaps.hasNext()) { var overlapSpan = overlaps.next(); gs.log("Dates: " + overlapSpan.getStart() + " - " + overlapSpan.getEnd()); }
0 REPLIES 0