- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 10:45 PM
Hi,
I have created the below script to set some date/time field values present on the process task (scopped application) table, which extends from the table which is in global scope.
I am getting below error if I run this in Background script with scope application.
"Background message, type:error, message: Use of Packages calls is not permitted in scoped applications"
var vari_start_date = '';
var p_task = new GlideRecord('x_awin2_integrate_process_task');
p_task.get('0219e240dbff634445f4550a4896191d');
p_task.query();
if(p_task.next()){
vari_start_date = p_task.parent.variables.u_start_date + ' 08:00:00';
var est = Packages.java.util.TimeZone.getTimeZone('US/Eastern');
var pst = Packages.java.util.TimeZone.getTimeZone('UK/Greenwich');
var estGdt = new GlideDateTime();
estGdt.setTZ(est);
var pstGdt = new GlideDateTime();
pstGdt.setTZ(pst);
estGdt.setValue(vari_start_date);
pstGdt.setValue(estGdt);
pstGdt.addSeconds(18000); // add 5 hours
p_task.new_hire_start_date = pstGdt;
p_task.update();
}
can anyone suggest me how to fix this issue. Thank You!
Regards,
Ganesh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 10:58 PM
@Community Alums
if your task is to convert timezone from US/Eastern to UK/GMT or UTC then no need of package call
check this script will work in scoped app as well and global
Enhance it as per your requirement
var strConvertedDateTime = new GlideScheduleDateTime(new GlideDateTime()).convertTimeZone("UTC", "IST");
var gdtConvertedDateTime = new GlideDateTime(strConvertedDateTime)
gs.info("UTC time:-> " + new GlideDateTime());
gs.info("Converted Time in IST:> " + gdtConvertedDateTime);
Output:
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 10:58 PM
@Community Alums
if your task is to convert timezone from US/Eastern to UK/GMT or UTC then no need of package call
check this script will work in scoped app as well and global
Enhance it as per your requirement
var strConvertedDateTime = new GlideScheduleDateTime(new GlideDateTime()).convertTimeZone("UTC", "IST");
var gdtConvertedDateTime = new GlideDateTime(strConvertedDateTime)
gs.info("UTC time:-> " + new GlideDateTime());
gs.info("Converted Time in IST:> " + gdtConvertedDateTime);
Output:
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader