How are you calling runtime?
# suitescript
k
How are you calling runtime?
n
Copy code
define(['N/sftp', 'N/encode', 'N/https', 'N/runtime'], runScheduled);
Copy code
function runScheduled(sftp, encode, https, runtime) { var scriptObj =  runtime.getCurrentScript(); }
k
What happens if you don't use scriptObj but instead use runtime.getCurrentScript everywhere it would occur?
oh! you've got two runtimes
if everything is inside your define, you should be able to call it from anywhere in the script instead of passing it to your function as an argument
n
Hm. Well, has always worked like that. Until today. Bizarre.
k
dunno why it would suddenly stop working, but that would be my next step in troubleshooting
The other way to handle it would be to define scriptObj before the function call and pass that as an argument instead of runtime
so that you're not duplicating the variable names
that would be better practice anyway since SuiteScript doesn't support const or let
n
I'll try that. Thank you!!
s
well SS2.1 supports const/let, no? admittedly that's still in the oven so to speak
and (obligatory plug) TypeScript supports it too, even for SuiteScript 1.0 🙂
k
yeah I only use typescript, but Nate here looks like he's using vanilla JS
c
5.1 (2.0) supports const but 2.1 supports all the things (let/const etc...)
s
2.0 allows
const
but as far as I recall it
const
has no semantics different from
var
in 2.0
i.e. it doesn't enforce that consts are constant 🙂
though I may be wrong - haven't tried using const in SS2.0 for a very long time
j
You're correct 2.1 script a const can't be reassigned, 2.0 it can
c
in 2.0 you can't reassign a const it'll error out
you can modify a const properties though
j
Really const x = 1; x = 2; doesn't error out for me in 2.0. That's server side by the way. Client side the browser will certainly object to that re-assignment
c
it errors out for me in a backend suitelet
its netsuite so consistency isn't exactly normal
s
it's like living in the The Matrix.