Last active
October 29, 2021 19:38
-
-
Save benjsicam/6260100 to your computer and use it in GitHub Desktop.
This code is a NetSuite Wizard or NetSuite Assistant which has a File Upload functionality.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* File Upload Wizard. | |
* @param {nlobjRequest} request Request object | |
* @param {nlobjResponse} response Response object | |
* @returns {Void} Any output is written via response object | |
*/ | |
function main(request, response) { | |
var assistant = nlapiCreateAssistant("File Upload Wizard", true); | |
assistant.setOrdered(true); | |
/* VERY IMPORTANT - Client side script for this wizard must be included. */ | |
assistant.setScript('customscript_file_upload_wizard_css'); | |
assistant.addStep('custstep_file_upload', 'Upload File').setHelpText("Upload your file."); | |
assistant.addStep('custstep_summary', 'Summary').setHelpText("Confirm details below."); | |
if (request.getMethod() == 'GET') { | |
if (!assistant.isFinished()) { | |
if (assistant.getCurrentStep() == null) | |
assistant.setCurrentStep(assistant.getStep("custstep_file_upload")); | |
var step = assistant.getCurrentStep(); | |
if (step.getName() == "custstep_file_upload") { | |
var fileField = assistant.addField('custpage_file', 'select', 'File'); | |
var uploadButton = assistant.addField('custpage_upload_btn', 'inlinehtml', 'Browse'); | |
var fileNameField = assistant.addField('custpage_file_name', 'text', 'File Name'); | |
fileField.setMandatory(true); | |
fileField.setDisplayType('disabled'); | |
fileNameField.setDisplayType('hidden'); | |
/* This is the upload button markup. The button ID is browse (id="browse")*/ | |
uploadButton.setDefaultValue('<table id="custbl_button"> <tbody> <tr> <td> <table id="tbl_select" cellpadding="0" cellspacing="0" border="0" style="margin-left:32px; cursor:hand;"> <tbody> <tr id="tr_select" class="pgBntG"> <td id="tdleftcap_select"> <img src="/images/nav/ns_x.gif" class="bntLT" border="0" height="50%" width="3"> <img src="/images/nav/ns_x.gif" class="bntLB" border="0" height="50%" width="3"> </td> <td id="tdbody_select" height="20" valign="top" nowrap="" class="bntBgB"> <input type="button" style="" class="rndbuttoninpt bntBgT" value="Browse" id="browse" name="browse" onmousedown="this.setAttribute(\'_mousedown\',\'T\'); setButtonDown(true, true, this);" onmouseup="this.setAttribute(\'_mousedown\',\'F\'); setButtonDown(false, true, this);" onmouseout="if(this.getAttribute(\'_mousedown\')==\'T\') setButtonDown(false, true, this);" onmouseover="if(this.getAttribute(\'_mousedown\')==\'T\') setButtonDown(true, true, this);"> </td> <td id="tdrightcap_select"> <img src="/images/nav/ns_x.gif" height="50%" class="bntRT" border="0" width="3"> <img src="/images/nav/ns_x.gif" height="50%" class="bntRB" border="0" width="3"> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table>'); | |
} else if (step.getName() == "custstep_summary") { | |
var fileUploadStep = assistant.getStep('custstep_file_upload'); | |
var fileField = assistant.addField('custpage_file_review', 'text', 'File'); | |
fileField.setDisplayType('inline'); | |
fileField.setDefaultValue(fileUploadStep.getFieldValue('custpage_file_name')); | |
} | |
} | |
response.writePage(assistant); | |
} else { | |
assistant.setError(null); | |
if (assistant.getLastAction() == "finish") { | |
assistant.setFinished("Your file has been processed."); | |
assistant.sendRedirect(response); | |
} else if (assistant.getLastAction() == "cancel") { | |
nlapiSetRedirectURL('tasklink', "CARD_-29"); | |
} else { | |
if (!assistant.hasError()) | |
assistant.setCurrentStep(assistant.getNextStep()); | |
assistant.sendRedirect(response); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment