copyDoc.saveAndClose();在参数列表Google Sheet Script之后丢失)

时间:2017-02-10 04:04:18

标签: google-apps-script

我不知道编码 - 我试图运行下面的脚本并在第79行的参数lis t之后收到错误丢失“copyDoc.saveAndClose();

  

块引用

以下是doc的网址: https://docs.google.com/document/d/1FcbVBHmCcDfjcaKXSU5UeaOD30h1d5yTyQp_s28VPzc/edit?usp=sharing

这是脚本。请指教。真诚的谢谢。

function myFunction() {

// rsaez@shsd.org
// Travel Request
// Get template from Google Docs and name it

    var docTemplate = "1FcbVBHmCcDfjcaKXSU5UeaOD30h1d5yTyQp_s28VPzc";

 // *** replace with your template ID ***

    var docName = "Travel_Request";

// When Form Gets submitted
function onFormSubmit(e) {
//Get information from form and set as variables

    var email_address = "rsaez@shsd.org, rsaez@shsd.org";
    var Building = e.values[5];
    var Request = e.values[6];
    var Total_Days = e.values[7];
    var Substitute_Needed = e.values[8];
    var Staff_Member_Type = e.values[9];
    var Coverage_Type = e.values[10];
    var Time_of_Day = e.values[11];
    var Coverage = e.values[12];
    var Request_Type = e.values[13];
    var Destination = e.values[14];
    var Purpose = e.values[15];
    var City = e.values[16];
    var State = e.values[17];
    var Purpose_is_related_to = e.values[18];
    var Registration = e.values[19];
    var Lodging = e.values[20];
    var Lodging_Cost = e.values[21];
    var Lodging_Total = e.values[22];
    var Meals = e.values[23];
    var Meals_Cost = e.values[24];
    var Meals_Total = e.values[25];
    var Mileage = e.values[26];
    var Other = e.values[27];
    var Travel_Cost = e.values[28];
    var Miscellanous = e.values[29];

// Get document template, copy it as a new temp doc, and save the Doc’s id

    var copyId = DocsList.getFileById(docTemplate)
    .makeCopy(docName+' for '+full_name)
    .getId();

// Open the temporary document

    var copyDoc = DocumentApp.openById(copyId);

// Get the document’s body section

    var copyBody = copyDoc.getActiveSection();

// Replace place holder keys,in our google doc template

    copyBody.replaceText('keyDate',
    copyBody.replaceText('keyName',
    copyBody.replaceText('keyPosition',
    copyBody.replaceText('keyBuilding',
    copyBody.replaceText('keyRequest',
    copyBody.replaceText('keyDayT',
    copyBody.replaceText('keySubstitute',
    copyBody.replaceText('keyStaff',
    copyBody.replaceText('keyDay',
    copyBody.replaceText('keyTime',
    copyBody.replaceText('keyCoverage',
    copyBody.replaceText('keyRequest',
    copyBody.replaceText('keyDest',
    copyBody.replaceText('keyPurpose',
    copyBody.replaceText('keyCity',
    copyBody.replaceText('keySt',
    copyBody.replaceText('keyPurpRelated',
    copyBody.replaceText('keyRT',
    copyBody.replaceText('keyLND',
    copyBody.replaceText('keyLCP',
    copyBody.replaceText('keyLT',
    copyBody.replaceText('keyMND',
    copyBody.replaceText('keyMCP',
    copyBody.replaceText('keyMT',
    copyBody.replaceText('keyMLT',
    copyBody.replaceText('keyOT',
    copyBody.replaceText('keyTotalBOE',
    copyBody.replaceText('keyMisc',

// Save and close the temporary document

    copyDoc.saveAndClose();

// copyDoc.saveAndClose() (options.cand_email);                     
// Convert temporary document to PDF

    var pdf = DocsList.getFileById(copyId).getAs("application/pdf"  

}

2 个答案:

答案 0 :(得分:0)

你的最后一行,

sleep()

最后似乎错过了')'。也许这就是缺失后的参数列表

答案 1 :(得分:0)

对于每个打开的saveAndClose(),在脚本执行结束时会自动调用Document方法。也许它会提供帮助:自2013年以来已弃用DocsList,请参阅https://developers.google.com/apps-script/sunset。您应该使用DriveApp代替。

var copyId = DriveApp.getFileById(docTemplate)
    .makeCopy(docName+' for '+full_name)
    .getId();

var pdf = DriveApp.getFileById(copyId).getAs('application/pdf');