Hi, Is it possible to attach CS to several buttons...
# suitescript
p
Hi, Is it possible to attach CS to several buttons in Portlet (type: Simple Form)?
portlet.clientScriptModulePath
triggers only pageInit, not the onclick event.
b
what does your button creating code look like
p
pl_list_of_buttons_js.js
cs_job_exec_for_portlet.js
b
you added your own button via html
so your onclick is basically evaled in the global window context
executeJobFromPortlet is not set on the window global so you get an error
p
There is no error.
But I get your point. The context differs. Any idea how to proceed? I guess stringifying a local function and passing it as a parameter to onclick is the best shot.
b
primary difference being fixing the syntax errors in your portlet
stringifying the function is pretty much the worse way to do it
the low effort and bad practice is to simply set the executeJobFromPortlet on the window global from your client script
the correct way is to add an id to your button so you can select it in your client script, then add an event listener to the click event
👍 1
the native way is to add a select field to represent your options and a submit button to post to a suitelet that does the work
p
Thank you for recommendation. I confirm it works 👍