https://netsuiteprofessionals.com logo
#suitescript
Title
# suitescript
n

NickSuite

03/31/2022, 4:37 AM
why isn't my client script, set via form.clientScriptModulePath, firing a pageInit?
b

battk

03/31/2022, 4:40 AM
what does the rest of the suitelet look like?
n

NickSuite

03/31/2022, 4:40 AM
It's not a suitelet. It's a UE.
b

battk

03/31/2022, 4:40 AM
thats the problem
n

NickSuite

03/31/2022, 4:40 AM
Why?
You are saying that for the pageinit to trigger, it should be deployed to that record?
b

battk

03/31/2022, 4:41 AM
use an actual client script
n

NickSuite

03/31/2022, 4:42 AM
but it also not triggering a function that is in the client script.
Copy code
var fld = form.getField({id: 'custrecord_update_bill'});

fld.defaultValue = `<a href="javascript:updateBill();">Update Bill</a>`;
it cannot find "updateBill"
b

battk

03/31/2022, 4:43 AM
that code expects updateBill to be set globally
you would need to set updateBill on the window global
which you can actually do via either an actual client script, or via the code added via clientScriptModulePath
n

NickSuite

03/31/2022, 4:43 AM
Understood. Let me try the window.global
Copy code
window.global.updateBill = function() {
    
}
like this?
b

battk

03/31/2022, 4:44 AM
no
the window represents the global scope in a browser window
Copy code
<a href="javascript:updateBill();">Update Bill</a>
runs in the global scope, so updateBill needs to be a function in that same scope
n

NickSuite

03/31/2022, 4:47 AM
window.updateBill = updateBill() ?
b

battk

03/31/2022, 4:56 AM
that would set the global updateBill to the output of updateBill()
unless your function returns a function, that will get you an error since
Copy code
<a href="javascript:updateBill();">Update Bill</a>
expects a function to be in the updateBill global variable
n

NickSuite

03/31/2022, 4:57 AM
Okay, it worked. Thank you.
Copy code
window.updateBill = updateBill;