2013-08-29 97 views
0

我已經創建了一個寫入電子表格的表單。 Apps腳本在onSubmit上運行並查找新數據併發送電子郵件給經理 經理收到帶批准按鈕的電子郵件。簡單的谷歌應用工作流程表格 - >電子表格 - >電子郵件管理器 - >更新電子表格和請求者

我無法將批准者回復發送回電子表格。

當批准者選擇按鈕消息「找不到腳本函數:的doPost」

var COLUMN_STATE = 4; //the number is the column # + 1 6 = column G (7th column) 
var COLUMN_APROVE = 5 
var STATE_APPROVED = "APPROVED"; 
var STATE_REJECTED = "REJECTED"; 
var STATE_MANAGER_EMAIL = "MANAGER_EMAIL"; 

var REQUEST_SPREADSHEET_ID = "0AkbHPyoRSG2DdDJpaWd1bGEzb19HY2pjVHdiQUhxNUE"; 

// Main tutorial function: For each row 
// - if it has recently been APPROVED or REJECTED by a manager, email the results to 

function onRequest() { 
    // This is the Request Spreadsheet 
    var ss = SpreadsheetApp.openById(REQUEST_SPREADSHEET_ID); 
    var sheet = ss.getSheets()[0]; 

    // Fetch all the data from the Request Spreadsheet 
    // getRowsData was reused from Reading Spreadsheet Data using JavaScript Objects 
    var data = getRowsData(sheet); 

    // For every Request 
    for (var i = 0; i < data.length; ++i) { 
    var row = data[i]; 
    row.rowNumber = i + 2; 
    if (!row.state) { 
     // This is a new Request 
     // Email the manager to request for approval. 
     sendReportToManager(row);// Update the state of the Request 
     sheet.getRange(row.rowNumber, COLUMN_STATE).setValue(row.state); 
    } 
    } 
    } 


// Sends an email to a manager to request approval 
function sendReportToManager(row) { 
    var subject = "ID#" + " " + row.rowNumber + " "+"Request for Time Off" 
    var message ='<form action="xxxx" method="Post">' + 
     "<P>" + "Request Id: " + row.rowNumber + "</P>"+ 
     "<P>" + row.username + " has requested your approval for Time Off." + "</P>"+ 
     '<input type="hidden" name="row" value="' + row.rowNumber +'" /> ' + 
     '<input type="submit" value="Submit" />' + 
     '</form>'; 
     //(Logger.log(row)); 
    MailApp.sendEmail(row.supervisorsEmail,subject, "", {htmlBody: message}); 
    row.state = STATE_MANAGER_EMAIL; 
} 

function doPost(e) { 
    var template = HtmlService.createTemplateFromFile('Thanks.html'); 
    template.name = e.parameter.name; 
    template.comment = e.parameter.comment; 
    template.screenshot = e.parameter.screenshot; 
    return template.evaluate(); 
    (Logger.log(e)); 
} 

回答

0

在​​3210的URL應該在發佈對話框中提供的一個。它將以/exec結束。你需要publish your script作爲一個web應用程序,它會給你一個URL,並確保你的doPost()方法在那裏被調用。

+0

我已經發布了該腳本,並在我的代碼中有URL。 「XXXX」僅僅是Https:// ..... – user2727623

+0

的佔位符您是否創建了新版本並在添加doPost後重新發布您的腳本?我複製了你的腳本,添加了一個html模板,併發布 - 它適用於我,所以這可能是一個簡單的問題。 – Mogsdad

+0

我發佈了一個新版本,它的工作原理:),謝謝。 – user2727623

相關問題