Very new to coding & concepts. This bit of code isn't what I want yet but it works well enough for the example. It adds a incremental number to the next filled row.
function onFormSubmit(e) {
var sheet = SpreadsheetApp.getActiveSheet();
var row = SpreadsheetApp.getActiveSheet().getLastRow();
sheet.getRange(row,1).setValue(row);
}
This part adds a menu choice PROCESS and allows users to choose Next Order in the menu. And I think I understand that I'm naming a custom function nextOpenOrder to use next...
function onOpen(e) {
SpreadsheetApp.getUi()
.createMenu('PROCESS')
.addItem('Next Order', 'nextOpenOrder')
.addToUi();
}
This then is my custom function which throws a browser box to prompt the user for the next order number as generated by the first bit of code.
function nextOpenOrder() {
var spreadsheet = SpreadsheetApp.getActive();
var settingsSheet = spreadsheet.getSheetByName('FormResponses3');
settingsSheet.activate();
var selectedRow = Browser.inputBox('Create Parts Order',
'Please enter the Order ID# to use' +
' (for example, "2"):',
Browser.Buttons.OK_CANCEL);
}
But the next step is to throw an html or pdf document. Eventual intent is to have a row's worth of data presented so the end user can enter a parts order in another piece of software. I've figured out how to make a generic panel present itself.
function showDialog() {
var html = HtmlService.createHtmlOutputFromFile('INDEX')
.setWidth(400)
.setHeight(300);
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.showModalDialog(html, 'My custom dialog');
}
My INDEX.html code:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
Hello, World!
</body>
</html>
However the problem I can't seem to resolve is that this last bit of code doesn't execute on it's own. I can run it from the script page and it will present a dialog box with the message. But it doesn't happen automagically when I hit PROCESS and choose an order #.
Something simple I'm sure, since I'm really green at this.
Can someone push me forward?
showDialog()to run after you click OK from the input box?if (selectedRow !== 'cancel') {showDialog();}