Does anyone know why this code works in `beforeLoa...
# suitescript
m
Does anyone know why this code works in
beforeLoad
for a user event script, but doesn't work in a Suitelet? In the Suitelet
window
appears to be
undefined
.
Copy code
form.addButton({
    id: 'custpage_cancel',
    label: 'Cancel',
    functionName: "window.open('" + revenueArrangementUrl + "','_self' );"
});
b
the code in functionName behaves differently depending on if you added a client script. If there is a client script, then netsuite expects that the code is supposed to be run on the module from the client script, so it tries to find the window key from the client script module (and fails). If there is no client script, then the code is treated as the onclick property of the button
🙌 1
m
That's very good to know. Confirmed that removing the reference to the client script file and
window.open
works as expected. Moved the redirect logic into the client script in this case. Thanks, @battk!!!