title: Passing a user selection into a function in apps script
body: <p>I am attempting to build a user interface for a spreadsheet (whether through a menu add on or sidebar) that asks a user to select from a dynamic list of 'templates'. I want each item in the list of templates to run the below function with var templateName being the users selection in the list. </p>
  
  <p>I have attempted a dynamic menu but this is not working for me</p>
  
  <p><a href="https://stackoverflow.com/questions/31539911/google-apps-script-dynamically-creating-spreadsheet-menu-items">Google Apps Script: Dynamically creating spreadsheet menu items</a></p>
  
  <p>Is this possible in apps script?</p>
  
  <pre><code>  function getTemplate(templateName){
    //Retrieves the template file and opens it to retrieve templates
    var getTemplateFile = DriveApp.getFilesByName('Evaluation Templates')
    while (getTemplateFile.hasNext())
    var openTemplates = getTemplateFile.next()
    var templateId = openTemplates.getId()
    var openSpreadsheet = SpreadsheetApp.openById(templateId)
    //Retrieves the template sheet tab by the name selected in the menu
    var getTemplateSheet = openSpreadsheet.getSheetByName(templateName)
  </code></pre>