最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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();
  
}

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();
  
}
Share Improve this question edited Sep 20, 2020 at 5:17 TheMaster 51.2k7 gold badges73 silver badges100 bronze badges asked Sep 19, 2020 at 20:05 Michael RobinsonMichael Robinson 491 silver badge4 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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]");

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论