Can anyone offer any advice on how to call a funct...
# suitescript
e
Can anyone offer any advice on how to call a function from a suitelet via window.opener? My UE loads a client script with
clientScriptModulePath
and in that client script there is a module defined which I am trying to call. I've tried
window.opener.functionName
as well as
window.opener.myModule.functionName
and both are undefined/not a function.
b
you are using suitescript 2.0, which uses amd modules to explicitly avoid browser globals
im not sure why you are trying to use window.opener
but if you need a global to use with it, then you need to explicitly set one in your client script
e
my UE sets a button in
beforeLoad
that pops up a suitelet, and when the user submits the suitelet (not a submit button, just a regular button) I need to pass the values back from the suitelet to the parent form
b
what will you do with the value
e
set a column on the current line of a sublist
b
probably will want to use the opener's require function
Copy code
window.opener.require(["N/currentRecord"], function(currentRecord) {
  var rec = currentRecord.get();
  // and so on
});
r
You could do window.opener.postMessage in the suitelet and then add a message event listener in the client script on the parent form.
e
Thanks, I'll try these
@battk
require
worked, thanks. The supply chain management bundle does something similar and that client script calls
var parentWindow = window.opener; parentWindow.SCM.ItemSubstitution.processPopupData({qty: qty, location: location, item: selectedItem, line: origLine, origItem: origItem});
I wonder how it's organized. At any rate, thanks again.
b
they either did ss1 or made their ss2 set window globals