作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在使用谷歌脚本创建休假申请表。用户提交表单后,它会向主管发送电子邮件。主管能够批准或拒绝,并能够从电子邮件本身说明拒绝的原因。但是用户会同时收到请求待处理电子邮件和需要信息电子邮件。
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);
}
预期:一旦用户提交请求表单
如果我犯了错误,我深表歉意,我还是个初学者。因此,请求您帮助我。
最佳答案
也许像这样更改 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/
只是一个简短的问题。为了节省时间,我们计划只创建一个打开浏览器并指向我们网站的应用程序。后续更新将提供其余功能。 根据您的经验,此应用会获得批准吗?如果不是,我需要做什么才能获得批准? 干杯,RJ 最
我是一名优秀的程序员,十分优秀!