1. Create a new suitelet script and deploy (check if it works correctly by clicking on the url)
Code:
function demoSimpleForm(request, response) { if ( request.getMethod() == 'GET' ) { var form = nlapiCreateForm('Simple Form'); form.addField('textfield','text', 'Text'); form.addField('datefield','date', 'Date'); form.addSubmitButton('Submit'); response.writePage( form ); } else dumpResponse(request,response); }
2. Create a new user event script to add button and deploy on the specific record
Code:
function beforeLoad_addButton(type, form) { form.addButton('custpage_buttonalert', 'custom Button', 'onclick_callClient()'); form.setScript('customscript444'); // where customscript444 is the client script id which you will create in step 3 }
3. Create a client side script, and save it do not specify the function,we calls the function from user event script
Code:
function onclick_callClient(){ var recID = nlapiGetRecordId(); var url = nlapiResolveURL('SUITELET', 'customscript442', 'customdeploy1')+'&entity=' + nlapiGetRecordId() + '&recordType=' + nlapiGetRecordType(); // where customscript442 is the script id of the userevent script in step 2 and customdeploy1 is the deployment id in step 2 document.location=url; }