When a user uploads a file via Suitelet and clicks Submit, they want to display a message before the changes are committed into their NetSuite account. If a user clicks Ok, proceed with the first file. If user clicks Cancel, they should be able to re-upload the file.
1. Create a client side script and specify a Save Record function by navigating to Customization > Scripting > Scripts > New > Client. Sample Save Record function below:
function csSuiteletSaveRecord(){
var checked = confirm('Are you sure you want to submit this record?');
if (checked){
return true;
} else {
return false;
}
}
2. Create a sample suitelet by navigating to Customization > Scripting > Scripts > New > Suitelet. Sample code below:
function sampleSuitelet(request, response){
if(request.getMethod() == 'GET'){
var formSS = nlapiCreateForm('Simple Suitelet Form', false);
var fldSampleTextEntry = formSS.addField('custpage_sampletext_entry', 'text', 'Enter Sample Text', null);
fldSampleTextEntry.setDefaultValue('Default Valuess');
fldSampleTextEntry.setDisplayType('normal');
//Set form Script - which is a client side script
formSS.setScript('customscript69'); //specify ID
formSS.addSubmitButton('Submit');
response.writePage(formSS);
}else{
arrParams = new Array();
arrParams['custparam_sampletext_entry'] = request.getParameter('custpage_sampletext_entry');
var intCustomerId = request.getParameter('custparam_custid');
nlapiSetRedirectURL('RECORD', 'customer', intCustomerId, true, arrParams);
}
}
Note: The key here is to set the form script context of the suitelet and specify a Save Record function. Specify a confirm pop-up via Javascript.
No comments:
Post a Comment