I created a script file: "scripts" with the following:
function CoolMath(x,y) {
return x + y;
}
In my event sheet, I then have an javascript action:
runtime.GlobalVars.SomeVar = CoolMath(1,1);
Auto complete all brought up what I typed, so I figured it would be valid, but its not. SomeVar never gets changed. I am assuming I need to somehow import "scripts.js"?
EDIT
Found the problem - I didn't have the property set correctly for "importsforevents.js". It was set to none. I also added "export" keyword to my function name edited the function call to m.CoolMath to reflect the import call.
Integration with scripts in events
Unlike legacy "classic" mode scripts, modules have their own top-level scope. This means things like a top-level function declaration is not available in other script files.
Instead you can add imports to the script file with the purpose Imports for events which then become available for scripts in events. See the section Using imports in Scripts in event sheets for more details.
Another option is to write globals as explicit properties of globalThis, e.g. globalThis.myFunction = function () { ... } and call it via globalThis.myFunction(), but using modules is preferable.