doPost(e)功能部分工作

时间:2018-03-20 08:50:52

标签: google-sheets

我有这个代码,它假设从外部来源获取信息,将消息发送回此来源以询问所需的操作,然后分析此响应,如果响应有' @'在文中,它会写"关闭"在某个特定的单元格中,然后发送确认此操作的消息。

最终,它从未奏效。发送第一条消息,但第二条消息 - 不是。并且特定细胞也没有变化。

我怎么知道我的问题在哪里?

 function doPost(e) 
    {
      var contents = JSON.parse(e.postData.contents);
      var text = contents.message.text;
      var id = contents.message.from.id;
      var name = contents.message.from.first_name + " " + 
      contents.message.from.last_name;
      sendText(id, 'Hi ' + name ,' please send your needed action'); //till here, everything works great


      if (/^@/.test(text))
      {
        var ss = SpreadsheetApp.getActiveSpreadsheet();
        var sheet = ss.getSheetByName("ServiceC");
        SpreadsheetApp.setActiveSheet(sheet);
        var getCallID = text.slice(1).split(" ")[0];
        getCallID = parseInt(getCallID,10);
        var cellToEdit = 'K' + (getCallID + 8) ;
        sheet.getRange(cellToEdit).setValue("close");
        sendText(id, 'now its closed');
      }

1 个答案:

答案 0 :(得分:0)

好的,我明白了!文字切片是错误的。我修好它,它就像一个魅力!