Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception: The parameters (String,DriveApp.File) don't match the method signature for DriveApp.File.makeCopy

I'm new to Script and was wondering if I could get help with a question. I'm currently trying to auto-fill a Google Doc from a Google Form submission. I've had success with a small test in the past, but since trying it a second time with a bit of a larger form, I'm encountering this error:

"Exception: The parameters (String,DriveApp.File) don't match the method signature for DriveApp.File.makeCopy"

It isn't immediately clear to me what this is telling me. What I do know is that I'm not doing anything differently than my last small scale test so the script I'm running looks on the surface to be solid, so I'm hoping someone could help me out with pointing out what's wrong. Here's the script:

function autoFillFormFromDoc(e) {

  var clientCode = e.values[1];

  var email = e.values[2];

  var warningSigns = e.values[3];

  var internalCopingStrategies = e.values[4];

  var peopleAndSocial = e.values[5];

  var peopleWhoCare = e.values[6];

  var creatingSafety = e.values[7];

  var clientName = e.values[8];

  var date = e.values[9];
  
  var templateFile = DriveApp.getFileById("1Vs8y3eZbyBlef8HlV7v9nhSRvaH39Cg5P0Q5zhpZBA");
  var templateResponseFolder = DriveApp.getFileById("1OxsOwU6rAvohqRqDVOfH_f70kvu30HZp");
  
  var copy = templateFile.makeCopy(clientName, templateResponseFolder);
  
  var doc = DocumentApp.openById(copy.getId());
  
  var body = doc.getBody();
  
  body.replaceText("{{ClientCode}}", clientCode);
  
  body.replaceText("{{Email}}", email);

  body.replaceText("{{WarningSigns}}", warningSigns);

  body.replaceText("{{InternalCopingStrategies}}", internalCopingStrategies);

  body.replaceText("{{PeopleAndSocial}}", peopleAndSocial);

  body.replaceText("{{PeopleWhoCare}}", peopleWhoCare);

  body.replaceText("{{CreatingSafety}}", creatingSafety);

  body.replaceText("{{ClientName}}", clientName);

  body.replaceText("{{Date}}", date);
  
  doc.saveAndClose();
  
}
like image 446
Michael Robinson Avatar asked Oct 23 '25 18:10

Michael Robinson


1 Answers

Issue:

File.makeCopy(name, destination) expects two arguments

  • name of type string and
  • destination of type folder

The script calls destination with type file. Therefore it errors out with

The parameters (String,DriveApp.File) don't match the method signature for DriveApp.File.makeCopy

Solution:

Get folder instead of file:

var templateResponseFolder = DriveApp.getFolderById("[FOLDER_ID]");
like image 149
TheMaster Avatar answered Oct 26 '25 08:10

TheMaster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!