Skip to content

Instantly share code, notes, and snippets.

@joeangel
Created July 13, 2021 09:34
Show Gist options
  • Save joeangel/41372f518ee88716d3498b551a23172c to your computer and use it in GitHub Desktop.
Save joeangel/41372f518ee88716d3498b551a23172c to your computer and use it in GitHub Desktop.

Code.gas

function doGet(e) {
  var form = FormApp.openById(e.parameter.form);
  var ss = SpreadsheetApp.create(e.parameter.name);
  var folder = DriveApp.getFolderById(e.parameter.folder);
  var file = DriveApp.getFileById(ss.getId());
  folder.addFile(file);
  DriveApp.getRootFolder().removeFile(file);
  
  form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId())
      .setTitle(e.parameter.name)
      .setAllowResponseEdits(true)
      .setAcceptingResponses(true)

  var s = ss.getSheets()[0];
  s.setName('Result');
  s.getRange('A1').setValues([['Timestamp']]);

  return ContentService.createTextOutput(form.getId() + "\n" + ss.getId() + "\n" + form.getPublishedUrl());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment