Scripts should not directly call Java packages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2022 10:29 PM
Actually, We directly call Java packages in the script. Is there any other way to call the java packages?
Can any one help me how to call the java packages in other way?
Script :
function Returnnextstrikedate(strikedon){
var striked = strikedon;
var strikedate = new GlideDateTime(striked);
var tz = Packages.java.util.TimeZone.getTimeZone('Europe/Oslo');
strikedate.setTZ(tz);
var timeZoneOffSet = strikedate.getTZOffset();
strikedate.setNumericValue(strikedate.getNumericValue() + timeZoneOffSet);
var dayOfWeek = strikedate.getDayOfWeek();
var today = new GlideDateTime();
var dayOfWeek1 = today.getDayOfWeek();
var tz2 = Packages.java.util.TimeZone.getTimeZone('Europe/Oslo');
dayOfWeek1.setTZ(tz2);
var timeZoneOffSet2 = dayOfWeek1.getTZOffset();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2022 11:17 PM
Hello Rama,
You can call java packages (JAR Files) from MID server by placing a JAR file on the MID server.
For more information please visit, https://docs.servicenow.com/bundle/rome-servicenow-platform/page/product/mid-server/task/t_Synchroni...
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2022 11:24 PM
Hello Sulabh,
Thanks for the quick responce.
Can we achieve this through the script? Because I don't want to include mid-server.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2022 01:37 AM
Hi Rama, If you use MID server, you can create script include and get the response of the JAR files (via MID server) and the use the same response in your script.
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2022 11:42 PM
Hi,
Package calls won't work in scoped app
For global scope it might work but not all
what's your exact requirement here?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader