hey all. according to my research in javascript yo...
# suitescript
l
hey all. according to my research in javascript you can call a function by function name in a string variable. but netsuite doesn't like this. is it possible?
so I need to call functionA(id, 'some_function_name'). then functionA does somthing inside but requiring to make a call to 'some_function_name'. some_function_name is not known till runtime.
e
What context or script type are you trying this out in? What do you mean "doesn't like this"? How does it fail?
l
suitelet form. ReferenceError: "window" is not defined.
r
your suitelet is executing on the server side, where the
window
object does not exist
☝️ 1
☝🏻 1
r
you probably don't need to use a string to call a particular function in the way you have in mind. you could put the string into a switch statement which calls the corresponding function, not using the string to actually call the function.
l
well i guess need to recode it differently.
r
Untitled.js
s
a more idiomatic way to handle this is to pass the function (not the function name) to your functionA() since functions are first class citizens in Javascript.
👀 1
e.g.
funA(exampleFunction)
rather than
funA("exampleFunction")
🙌 1
this 2
☝️ 1
e
For sure this ^