gpt4 book ai didi

javascript - 函数 doGet 在请假审批脚本中不起作用

转载 作者:行者123 更新时间:2023-11-30 06:13:01 26 4
gpt4 key购买 nike

我目前正在使用谷歌脚本创建休假申请表。用户提交表单后,它会向主管发送电子邮件。主管能够批准或拒绝,并能够从电子邮件本身说明拒绝的原因。但是用户会同时收到请求待处理电子邮件和需要信息电子邮件。

function sendEmail(e) {
var Email = e.values[1];
var Name = e.values [2];
var LeadEmail = e.values [3]
var StartDate = e.values[4];
var EndDate = e.values[5];
var Reason = e.values[6];

var url ='https://script.google.com/macros/s/AKfycbwtoHhUZPX2bEbbdiEjak4WwUZYBj5ulrSbUJlDzemgcqTMIG0/exec';
var resubmitFormUrl='https://docs.google.com/forms/d/e/1FAIpQLSdNAeCsbTfntizgpMeOdbJdiWKRQKngo0hWsFaUmECFVMt94w/viewform?usp=sf_link'

var approve = url + '?approval=approve'+'&reply='+Email;
var reject = url + '?approval=reject'+'&reply='+Email;
var moreinfo = url + '?approval=moreinfo'+'&reply='+Email;

var html ="<body>"+
"<h2>Please review</h2><br />"+

"Email id : " + Email + "<br/>"+
"Name : " + Name + "<br/>"+
"Lead Email ID: " + LeadEmail + "<br/>"+
"StartDate : " + StartDate + "<br/>"+
"EndDate : " + EndDate + "<br/>"+
"Reason : " + Reason + "<br/>"+

"<a href ="+ approve +"> Approve</a><br />"+
"<a href ="+reject+">Reject</a> <br />"+
"<a href ="+moreinfo+">MoreInfo</a> <br />"+
``` "</body>";

MailApp.sendEmail(LeadEmail, "Approval Request", "what no html?", {htmlBody: html});

var htmll ="<body>"+
"<h3>You have submitted these details</h3>"+

"Email id : " + Email + "<br/>"+
"Name : " + Name + "<br/>"+
"Lead Email ID: " + LeadEmail + "<br/>"+
"StartDate : " + StartDate + "<br/>"+
"EndDate : " + EndDate + "<br/>"+
"Reason : " + Reason + "<br/>"+

``` "<h3>You'll be notified soon about the approval ```decision</h3>"+
"<body/>";

MailApp.sendEmail(Email,"Approval Request","What no html?",{htmlBody:htmll});

var html2 ="<body>"+
`` "<h3>You have submitted the below details,but Approver require more information</h3>"+

"Email id : " + Email + "<br/>"+
"Name : " + Name + "<br/>"+
"Lead Email ID: " + LeadEmail + "<br/>"+
"StartDate : " + StartDate + "<br/>"+
"EndDate : " + EndDate + "<br/>"+
"Reason : " + Reason + "<br/>"+


"<h3>click the link </h3><a href = "+resubmitFormUrl+">Re-Submit </a> <h3>form for Approval</h3> "+

"<h3>You'll be notified soon about the approval decision</h3>"+
"<body/>";

````MailApp.sendEmail(Email,"Approval Request","What no html?",{htmlBody:html2});

}

function doGet(e)
{
var answer = (e.parameter.approval==="approve") ? 'is Approved': (e.parameter.approval==="reject") ? 'Not approved' : 'Requires More Information' ;

var msg = "Your leave is: " + answer ;
if(e.parameter.approval != "moreinfo")
MailApp.sendEmail(e.parameter.reply,"Approval Request",msg);


}

预期:一旦用户提交请求表单

  1. 应向用户发送确认电子邮件以及向主管发送批准电子邮件
  2. 点击批准链接后,应向用户发送一封电子邮件,说明休假已获批准。
  3. 点击拒绝链接后,应向用户发送一封电子邮件,说明休假已被拒绝。
  4. 点击“需要信息”链接后,应向用户发送一封电子邮件,要求他提交更多信息,说明他应发送休假原因

如果我犯了错误,我深表歉意,我还是个初学者。因此,请求您帮助我。

最佳答案

也许像这样更改 doGet 会有帮助? (我无法确定):

function doGet(e) {
var answer = '';

// Checks for each value ('approve', 'reject', or 'moreinfo') separately
// Now, 'moreinfo' is not assumed by default (might matter)
if (e.parameter.approval === "approve") { answer = 'is Approved'; }
else if (e.parameter.approval === "reject") { answer = 'Not approved'; }
else if (e.parameter.approval === "moreinfo") { answer = 'Requires More Information'; }

// In case e.parameter.approval somehow matches none of the above
else { answer = "Undetermined yet -- please contact us"; }

var msg = "Your leave is: " + answer;

// Uses strict equality (might matter)
if (e.parameter.approval !== "moreinfo"){

// Includes curly braces around statement (probably unnecessary)
MailApp.sendEmail(e.parameter.reply, "Approval Request", msg);
}
}

关于javascript - 函数 doGet 在请假审批脚本中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57773522/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com