title: Calling a function in Google Apps Script
body: <p>Looked around everywhere for this with no real luck. </p>
  
  <p>I'm looking to call a function into another function using google apps scripts. Both functions are in the current project yet when I do, the function I am calling is not being pulled through as variables are not linking between the two functions</p>
  
  <p>The function I wish to call is called ' <code>getDates</code> ' which has the variable ' <code>year</code> ' in it. However when I call the function then the script goes to call ' <code>year</code> ' it is returning undefined. </p>
  
  <p>This is the <code>getDates</code> Function:</p>
  
  <pre><code>  function getDates {
   var startDate = new Date(sheet.getRange("B1").getValue());
  var year = startDate.getFullYear();}
  </code></pre>
  
  <p>And I am looking to call this function into the following:</p>
  
  <pre><code>    function one {
  
           getDates();
  
            var url = "https://(hidden url)" + year; 
  
          UrlFetchApp.fetch(url);
          var dataAll = JSON.parse(response.getContentText()); //
    var dataSet = dataAll;
  
    var rows = [],
        data;
  
  
    for (i = 0; i &lt; Object.keys(dataSet).length; i++) { data = dataSet[Object.keys(dataSet)[i]]; rows.push([data.XXX]); }
  
  
    dataRange = sheet.getRange(7, 2, rows.length, 1); 
    dataRange.setValues(rows);
      }
  </code></pre>