Can I use clientScriptModulePath, to attach a func...
# suitescript
a
Can I use clientScriptModulePath, to attach a function to a button in view mode?
s
yes
a
@Sandii where should I add the function? pageInt?
s
It should be a separate function in the client script (not an entry point. Make sure the client returns it.
a
Make sure the client returns it. could you please explain this?
s
usually at the bottom of your client script, there is a return object, that has all the functions that can be called (these are usually the entry points), you need to add your new function to that list
the exact syntax depends on the formatting you prefer
a
so I don't need to add any entry point
I can just add the function and return it
like
return {myFunction: myFunction}
s
Yep, if it does not like that (something like your client script does not exist), then also add a
pageInit: pageInit
that does nothing if you need to actually create the client script scripted record. I can't remember if you need to do that when using form.clientScriptModulePath on a native record or not.
1000 1
a
and do I need to deploy the client script or just add it to the file cabinet is ok?
s
yeah, i usually have to add a blank pageInit function to make it work for me. I think Netsuite expects attached client script to implement at least one entry point function even if you won’t actually use it
You should not need to deploy it
a
Thanks
s
Also if you button is doing something very simple, you can just add the function inline in the creation of the button instead of creating another file.