thwippp
1/10/2017 - 5:10 PM

A simple prompt- Google Sheets

A simple prompt- Google Sheets

/******************************
This is a prompt template that returns the response to be used in another function:
(var returnedValue = functionName();)

It can tell whether you clicked cancel or exited and do something with those results
******************************/

function functionName() { // Function name
  var ui = SpreadsheetApp.getUi();
  var response = ui.prompt('Where would you like to insert the next entry?', ui.ButtonSet.OK_CANCEL);

  if (response.getSelectedButton() == ui.Button.OK) { // If the user clicked ok, get their response
    
    //Logger.log(response.getResponseText());
    return response.getResponseText();
    
  //To tell the user what they put
  } else if (response.getSelectedButton() == ui.Button.CANCEL) {
   Logger.log('The user canceled the dialog.');
  } else {
   Logger.log('The user closed the dialog.');
  }
}