How to use gs.include in scoped application?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 02:26 AM
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:
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 09:53 PM
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
name | String | Name of the script to include. |
ReturnsType Description
Boolean | Flag that indicates whether the script include worked. Possible values:
|
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");
}
}
Regards,
Sid