Calling ClientScript from Suitelet
Category : NetSuite suitescript SuiteScript 2.0
Suppose there is a scenario where we want to create a form and we want to perform some action on the client side as in UI of netsuite. So what a can do for the better netsuite customization that we tell you in this tutorial of as a netsuite solution provider.
In Simple words we have to write a suitelet which can call a client script on click of button and that button is in the netsuite suitelet form. In this netsuite training we will tell you step by step procedure.
We are considering this netsuite training for beginners:
Step 1: Define a function callclientscript() inside a client side script
Step 2: Deploy that script to record where
you want the function to be executed.
Step 3: write Code Snippet: suitescript 1.0
function
clientscripttest()
{
alert(“the function inside client script”);
return true;
}
Step 4: Note of the ID of the Script -> customscrip_xyz
Step 5: create a suitelet and define a function addButtontest() inside a suitelet.
Step 6 : call form.setScript(‘customscript110’) inside the addButtontest () function
Step 7: call form.addButton(‘custombutton’,’NetSuite Training’, ‘ clientscripttest ()’) inside the
addButtontest () function, specifying
clientscript() as your button script.
Code Snippet Example: suitelet
function addButtontest (request,response)
{
if (request.getMethod() == ‘GET’)
{
var form = nlapiCreateForm(‘Simple Form’);
var field = form.addField(‘textfield’,’text’,’Text’);
form.setScript(‘ customscrip_xyz ‘);
form.addButton(‘custombutton’,’Show Message’, ‘clientscript()’);
response.writePage(form);
}
else
{
var html = ‘<html><body><h1>My new page</h1></body></html>’;
response.write(html);
}
} Test the above scripts and let us know f there is any question in Comments
Feel free to reach out TheSmilingCoders for proper netsuite solution provider, netsuite implementation, netsuite consultation , netsuite customization, netsuite Support,netsuite Training contact us at:
Email : [email protected]
Linkedin : https://www.linkedin.com/company/netsuite-academy/