- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2022 09:01 PM
To be specific, I'm working in scoped application Qualys one, there I need to convert timezone, it seems it is not working there using Javapackages, can anyone help? Also I am trying to debug using fix script but it is not printing any output
I tried this thing also
var time = new GlideDateTime(); // Display date retrieved
gs.print('GMT Time: '+time); // Set timezone
var tz = Packages.java.util.TimeZone.getTimeZone("America/New_York");
//var tz = Packages.java.util.TimeZone.getTimeZone("IST");
time.setTZ(tz); // Get offset of timezone set above
var timeZoneOffSet = time.getTZOffset(); // Add offset to current time
time.setNumericValue(time.getNumericValue() + timeZoneOffSet); // Print date/time in desired timezone
gs.print('Eastern time: '+time);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2022 09:30 PM
Hey,
Package calls aren't allowed in scoped applications. If you want to change the Timezone of a GlideDateTime object you can use the following.
var now = new GlideDateTime();
gs.print("System Time is " + now);
var gsdt = new GlideScheduleDateTime(now);
gsdt.setTimeZone("Europe/London");
gs.print("London time is " + gsdt.getGlideDateTime().getDisplayValue());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2022 09:30 PM
Hey,
Package calls aren't allowed in scoped applications. If you want to change the Timezone of a GlideDateTime object you can use the following.
var now = new GlideDateTime();
gs.print("System Time is " + now);
var gsdt = new GlideScheduleDateTime(now);
gsdt.setTimeZone("Europe/London");
gs.print("London time is " + gsdt.getGlideDateTime().getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2022 09:36 PM
Error facing
Evaluator.evaluateString() problem: com.glide.script.fencing.MethodNotAllowedException: Function print is not allowed in scope sn_vul_qualys. Use gs.debug() or gs.info() instead: com.glide.script.fencing.ScopedScriptableObject.checkWhitelistAccess(ScopedScriptableObject.java:137)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2022 09:43 PM
Hi,
please use gs.info() in scoped app instead of gs.print()
Regard
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2022 09:56 PM
Now its not throwing error but not printing anything