How to use gs.include in scoped application?

jusfory1
Tera Expert

Hi all,

 

Here is a script includes "underscorejs" created in global scope, and i want to include it in other scoped application, so i try to validate it in background runner and got test results like bellow, any other configurations did i miss?

  • it not work in scope application:
gs.include("underscorejs") // gs.include("global.underscorejs") not work;
var even = _.find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
gs.info('---> even: ' + even);
//system printed error: "Evaluator: com.glide.script.RhinoEcmaError: "_" is not defined."
  • it works in global application:
gs.include("underscorejs")
var even = _.find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
gs.info('---> even: ' + even); // print 2

 and script defination:

jusfory1_0-1715332976135.png

 

1 REPLY 1

Sid_Takali
Kilo Patron
Kilo Patron

Hi @jusfory1 

 

Scoped GlideSystem - include(String name)

Provides a safe way to call a script include from the sandbox, allowing only the inclusion of trusted scripts.

ParametersName Type Description
nameStringName of the script to include.
ReturnsType Description
BooleanFlag that indicates whether the script include worked.
Possible values:
  • true: Script include worked.
  • false: Script include failed.

 

 

var ldapServer = new GlideRecord("ldap_server_config");
ldapServer.addActiveQuery();
ldapServer.query();
gs.include("LDAPUtils");
var ldapUtils = new LDAPUtils();
var errMsg = "";
while (ldapServer.next()) {
  var ldap = new GlideLDAP();
  var dn = ldapServer.dn;
  var env = ldap.setup();
  if (env == null) {
    errMsg = "Failed environment setup, missing URL";
    gs.eventQueue("ldap.connection_failed",   ldapServer, ldapServer.getDisplayValue(), errMsg);
    gs.logError("LDAP server " + ldapServer.getDisplayValue() + " failed scheduled connection test: " + errMsg, "LDAP");
 }
}

 

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...

 

 

Regards,

Sid