i have a client script which opens a suitelet. wh...
# suitescript
b
i have a client script which opens a suitelet. when the suitelet is done, I want it to send back a small bit of "<script>" which calls a function that exists in the client script that opened it (essentially pass back data by calling the client-script function). in SS1.0 this was easy, as all of the functions in the calling client script were "global" ... how do I do this in SS2 ?
b
You have access to the require function of the opening window
b
yes ... i just don't know the syntax of doing that. do you have a line of script handy to show how that's done?
a
@Boban Dragojlovic You can: • You client script send the request to the Suitelet and it will get a response back(send the data you want back in the response from the Suitelet.) • Create a module with the function and load/include that module in your Client Script and Suitelet Script.
b
As in how to use the require function
b
how do I access the "opener's" require ?
b
Or how to use window.opener
b
is it var x = window.opener.require ?
or var x = window.opener.require("/script...") ?
b
your usage of var x suggests that its a how do you use require sort of deal
b
i don't know how to de-reference to the opener
i know I can do var x = require("...") and then x.callSomeMethod()
b
b
but if I send that back from my suitelet, that will only run "in that suitelet" window ... and not on the opener
b
except you use window.opener.require([dependencies,] callback)
b
got it. so var x = windows.opener.require(...) and then x.somemethod()
b
i mean you could if the module is loaded on the page already
but I personally would use the callback