why isn't my client script, set via form.clientScr...
# suitescript
n
why isn't my client script, set via form.clientScriptModulePath, firing a pageInit?
b
what does the rest of the suitelet look like?
n
It's not a suitelet. It's a UE.
b
thats the problem
n
Why?
You are saying that for the pageinit to trigger, it should be deployed to that record?
b
use an actual client script
n
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
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
Understood. Let me try the window.global
Copy code
window.global.updateBill = function() {
    
}
like this?
b
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
window.updateBill = updateBill() ?
b
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
Okay, it worked. Thank you.
Copy code
window.updateBill = updateBill;