特定列中最后修改的单元格的调用值

时间:2018-04-01 03:55:28

标签: forms google-apps-script trello submission

使用google-script格式化提交时谷歌表单回复的电子邮件。此外,它还通过相同的电子邮件创建了一张Trello卡。

在此电子表格中,表单发布者将整数(如计数器)写入每个表单条目的特定列。目前我们达到264或者其他什么。我想在电子表格的“S”列中引用值(在本例中为表单提交的计数器编号),该列收集表单提交,以便它包含在脚本正在撰写的电子邮件的主题行中。

该脚本有效,但我无法弄清楚如何将列“S”中的单元格的新值拉入电子邮件主题。

function init() {

  var triggers = ScriptApp.getProjectTriggers();
  var form = FormApp.getActiveForm();

  // Delete all triggers before making a brand new one.
  for(var i in triggers) {
    ScriptApp.deleteTrigger(triggers[i]);
  }

  // Set up a new trigger
  ScriptApp.newTrigger('submitToTrello')
       .forForm(form)
       .onFormSubmit()
       .create();

  Logger.log('Successful creation of new submitToTrello trigger.');

}


function submitToTrello(e) {

  var form = FormApp.getActiveForm();
  var latestItemResponses = form.getResponses().pop().getItemResponses();


  if (MailApp.getRemainingDailyQuota() > 0) {
    // Trello email address goes here
    var email = "matt@elevenaudiodesign.com";
    var trello = "mattshane+nb0dbsbponwfb4zegqjx@boards.trello.com";
  };

  // Subject line will be the title of the event on Trello card
  var category = latestItemResponses[0].getResponse();
  var subject = latestItemResponses[1].getResponse();
  var date = latestItemResponses[3].getResponse();
  var tech = latestItemResponses[2].getResponse();

  // Intial empty body
  var body = "";

  // Loop through recent responses and format them into string
  latestItemResponses.forEach(function (value, index, array) {
    var formatted = Utilities.formatString("*** %s ***\n %s\n\n", value.getItem().getTitle(), value.getResponse());
    body = body.concat(formatted);
  });

  MailApp.sendEmail(email, "[ "+category+" ] "+subject+" // "+tech+" // "+date,       body);
  MailApp.sendEmail(trello, "[ "+category+" ] "+subject+" // "+tech+" // "+date, body);  
}

0 个答案:

没有答案