This sample suitelet will add a custom button that when clicked will call a function from another SuiteScript (a client script).
1. Create a Client Side Suitescript with the code to be executed when a button is clicked on the Suitelet form. Sample Code below:
var cust_field = nlapiGetFieldValue('customerfield');
alert('The Custom Select Field value is: '+cust_field);
}
2. Create a new Client Script in Netsuite by going to Customization > Scripting > Scripts > New > Client. Upload the script file.
3. Get the script id (e.g. customscript101).
4. Create a Suitelet by going to Go to Customization > Scripting > Scripts > New > Suitelet. Script file should create the form with additional buttons. Use the setScript method and set the id of the client script. On the addButton method, indicate the function name as the script parameter. Sample code below:
{
if ( request.getMethod() == 'GET' )
{
var form = nlapiCreateForm('Simple Form');
var field=form.addField('customerfield', 'select', 'Customer', 'customer');
form.setScript('customscript101');
form.addButton('custpage_button','Alert', "talert();");
response.writePage( form );
}
}
5. Deploy the script.
Additional Illustrations below
No comments:
Post a Comment