Scripts should not directly call Java packages

Rama Rao
Tera Contributor

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();

7 REPLIES 7

Sulabh Garg
Mega Sage
Mega Sage

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

Please Mark Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg

Hello Sulabh,

Thanks for the quick responce.

Can we achieve this through the script? Because I don't want to include mid-server.

 

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.

 

Please Mark Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader