1

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?

5
  • You want showDialog() to run after you click OK from the input box? Commented Dec 13, 2018 at 17:58
  • Correct. Eventually what I want to happen is that they click OK and it will take a row of data out of the sheet and show it for processing. Commented Dec 13, 2018 at 18:18
  • You need to capture the return from the input box and then run some more code. if (selectedRow !== 'cancel') {showDialog();} Commented Dec 13, 2018 at 18:58
  • Perfect Thanks! Commented Dec 13, 2018 at 19:14
  • Here's an example for you to take a look at. It's just a simple webapp which you can also run as a dialog. It has javascript functions that communicate with the server functions to read and write data to the spreadsheets. Commented Dec 13, 2018 at 20:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.