Hi,
I have developed a Suitelet that creates a form. Once the submit button on the form is pressed the Suitelet uses the values entered to create a PDF using BFO and displays the PDF on the screen. This all works perfectly, but the end users have now asked for another button that will email the PDF to a customer. Ideally the form will include two buttons, view PDF and email PDF. I am not sure how to do this as only one submit button can be used per Suitelet Form. I recognize you can add a custom button to the form which calls a function in a client script, but how do you pass the form's values to the client script function?
Below is a simplified version of my code that illustrates what I am trying to do.
function htmlSuitelet(request, response) { var recId = request.getParameter('ID'); if (request.getMethod() == 'GET' ) { var form = nlapiCreateForm('Custom Form'); form.setScript('my_client_script'); var frmRecId = form.addField('custpage_id', 'text', 'Customer Internal ID', null, null); form.setFieldValues({custpage_id:recId}); frmRecId.setDisplayType("hidden"); var statementYear = form.addField('custpage_year', 'text', 'What year would you like the gift statement to be generated for?', null, null); // ************* This is the part that Doesn't work ****************** // The button successfully calls the client script and runs the function, but I don't know how to pass the client script the values off of the form? form.addButton('sendEmail', 'Email Statement', 'emailStatement(custpage_year, custpage_id)'); form.addSubmitButton('View Statement'); response.writePage( form ); } //This code works and is ran when the form is submitted using the submit button else{ var statementYear = request.getParameter('custpage_year'); var recId = request.getParameter('custpage_id'); printDonationStatement(recId, statementYear, todaysDate); } }