Fluent App: Can i invoke Script Include in ECMAScript Module? Feature or bug?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 01:08 AM
Hi all
I am tring to develop my fluent app, and i want to invoke Script Include in ECMAScript Module, but it failed, details:
/****test script run in background script ****/
gs.info('>>>: prefix: ' + x_my_scope.CONSTANTS.PREFIX)
new SampleClass().whoAmI();
new SampleClass().infoPrefix()
/**** result ****/
x_my_scope: >>>: prefix: x_my_scope
x_my_scope: >>> whoAmI: SampleClass
Script execution error: Script Identifier: null.null.script, Error Description: "x_my_scope" is not defined., Script ES Level: 200
Evaluator: com.glide.script.RhinoEcmaError: "x_my_scope" is not defined.
script : Line(16) column(0)
Fluent Definations:
/**** file: CONSTANTS.now.ts ****/
import { Record } from '@servicenow/sdk/core';
import '@servicenow/sdk/global';
Record({
$id: Now.ID['x_my_scope.CONSTANTS'],
table: 'sys_script_include',
data: {
access: 'public',
active: true,
api_name: 'x_my_scope.CONSTANTS',
client_callable: false,
mobile_callable: false,
name: 'CONSTANTS',
sandbox_callable: false,
script: script`
var CONSTANTS = {
PREFIX:'x_my_scope',
}
`,
sys_name: 'CONSTANTS',
},
});
/**** file: SamleClass.now.ts ****/
import { Record } from '@servicenow/sdk/core';
Record({
$id: Now.ID['x_my_scope.SampleClass'],
table: 'sys_script_include',
data: {
access: 'public',
active: true,
api_name: 'x_my_scope.SampleClass',
client_callable: false,
mobile_callable: false,
name: 'SampleClass',
sandbox_callable: false,
script: script`
const {SampleClass} = require('./src/server/sample-class.js');
`,
sys_name: 'SampleClass',
},
});
/**** file: sample-class.js ****/
import { gs } from "@servicenow/glide"
export class SampleClass {
whoAmI() {
gs.info('>>> whoAmI: ' + this.constructor.name);
}
infoPrefix() {
gs.info('>>> infoPrefix: ' + x_my_scope.CONSTANTS.PREFIX);
}
}
#fluent #SDK
0 REPLIES 0