With SS 2.1 using `N/runtime` like this in a const...
# suitescript
e
With SS 2.1 using
N/runtime
like this in a constants file results in
All SuiteScript API Modules are unavailable while executing your define callback.
In SS 2.0, no issues. Any ideas for a workaround?
b
probably want to be more fair, your code couldnt run in 2.0
e
Aye, fair enough lol
b
after that, support case, though maybe @Ashwin K. could provide more context
s
I suspect the issue here is your arrow function is invoked, which in turn forces use of the
runtime
module as it populates that return object You might try instead exporting a function that takes no arguments and returns that same object, if ye like.
as an aside, an arrow function that returns a single expression can skip the return statement and function open/close {}
e
I tired that, same result. (And thanks for the aside.) I'll go another route
b
what was the working 2.0 code?
e
simply a custom module returning an object and a script including the constants in the define
I'll provide both later this evening, it's school project time. Home schooling fun
Editing the script record doesn't result in the error.
b
turns out that N/runtime is different in 2.1 vs 2.0
for 2.1, the getter for the envType is
function get() { [native code] }
for 2.0, the getter is
function () { return invoker(scriptSessionContext, "getEnvironment"); }
im guessing the native code does not like being run during the define callback
annoyingly I had to use
Object.getOwnPropertyDescriptor(runtime, 'envType').get.toString()
to get that information from a log
the 2.1 debugger was not useful enough
s
native code rocks
e
Anyone have any suggestions on how to handle configuration/constants between environments?
b
Do whatever works, it will be rendered useless anyways after a sandbox refresh
e
Ugh, I keep forgetting that.
s
If simple, we tend to use script parameters. If it gets more complex, we use a custom record to keep config centralized.
e
Do you load that custom record into cache?
s
if M/R script, yes. Other scripts have a single stable memory space so don't need it. In basic scripts I just do
const config = new ConfigRecord(1)
(NFT)