Function getSysTimeZone is not allowed in scope

Niels Aksel
Tera Guru

Need some help here,

For reporting purposes, we have created a database view in the sn_hr_core scope to join the tables task_sla and hr_core_case_workforce_admin.

Here is a screenshot of the database view:

find_real_file.png

The database view is working fine but when we try to build a report, we get the following error:

Function getSysTimeZone is not allowed in scope sn_hr_core

find_real_file.png

 

How do I fix this?

This is not only the case for the HR scope, but for all scoped applications with a database view using task_sla

(I have tested this on my developer instance)

 

 

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

I don't think you can fix this directly. It's built in to 4 script includes and 3 business rules that call gs.getSysTimeZone(). The development team either needs to make that function available to scoped apps or create a scoped equiv. and update those 7 files.

I invite you to open an enhancement request! Our product managers DO listen.

Enhancement requests: Tell us how you would improve the ServiceNow product 

View solution in original post

9 REPLIES 9

Paul St_ Martin
Kilo Contributor

I'm using a scoped app on the London release. I just created an indicator source using a view as the fact table.  The initial save went fine, but when I open the indicator source then return to the list of sources I get this error in the heading.

What is the impact of this error? 

Can I use my new source? 

Is there a workaround?

 

Thanks!

 

Community Alums
Not applicable

The workaround is to make a script include in global that calls the function you need (e.g. gs.getSysTimeZone()) and make that script include available to all scopes. You can then call it from your scoped app. It's a bit of a hack and this script include will not be part of your scoped app so you'll have to maintain it separately. Note, none of this code has been tested. Example:

var myGlobalUtils = Class.create();
myGlobalUtils.prototype = {
    initialize: function() {
    },

    getSysTimeZone : function() {
        return gs.getSysTimeZone();
    },

    type: 'myGlobalUtils'
};

 

Then you call global.myGlobalUtils().mygetSysTimeZone() from your scoped app and get the result you want.

The workaround is to make a script include in global that calls the function you need (e.g. gs.getSysTimeZone()) and make that script include available to all scopes. You can then call it from your scoped app. It's a bit of a hack and this script include will not be part of your scoped app so you'll have to maintain it separately. Note, none of this code has been tested. Example:

var myGlobalUtils = Class.create();
myGlobalUtils.prototype = {
    initialize: function() {
    },

    getSysTimeZone : function() {
        return gs.getSysTimeZone();
    },

    type: 'myGlobalUtils'
};

Then you call global.myGlobalUtils().mygetSysTimeZone() from your scoped app and get the result you want.

Thanks Chuck - to be clear, I don't explicitly call getSysTimeZone. In my new indicator source I have a condition checking a specific date against a datetime field in the database view.  Do you think your work around still applies?  If so, how would I use call it in the condition builder?

find_real_file.png

While my PA knowledge isn't that great, if there's a place to call this function, you can call the workaround one from the script include in the same way.