title: Create a Unique Sequential ID Generator - Google Scripts
body: <p>I am attempting to find a way to create a google scripts function that will create unique sequential ID generator after looking through my google sheets document verifying that it will be a unique ID. I found this answer <a href="https://stackoverflow.com/a/58515330/14143011">https://stackoverflow.com/a/58515330/14143011</a> which is exactly what I need however I do not want the ID to be inserted into the google sheet automatically, as I want to be able to use the ID in another function I am working on. When it comes to the date I am using this google scripts function to retrieve the current date:</p>
  <pre><code>const timezone = SpreadsheetApp.getActive().getSpreadsheetTimeZone();
  
  function datestamp() {
    var datestamp_format = &quot;yyyy-MM-dd&quot;;
    return Utilities.formatDate(new Date(), timezone, datestamp_format);
  }
  </code></pre>
  <p>To clarify what I am attempting to do, I have this function which creates folders for files I am uploading:</p>
  <pre><code>function createSubfolder(){
    var dropbox = Utilities.formatDate(new Date(), &quot;US/Eastern&quot;, &quot;_yyyy-MM-dd&quot;);
  </code></pre>
  <p>I want to change the name to also contain the generated ID. I want the 'createSubfolder' function to call the function that generates the ID and return it to a variable such as this:</p>
  <pre><code>function createSubfolder(){
        var generatedID = idGeneratorFunction()
        var dropbox = generatedID + Utilities.formatDate(new Date(), &quot;US/Eastern&quot;, &quot;_yyyy-MM-dd&quot;);
  </code></pre>
  <p>Thank you!</p>