我有一张表格链接到客户投诉表格。我想要它,以便当投诉升级到单元格中列出的某个人(H列)时,它会通过电子邮件通知该人告诉他们他们需要查看的问题。我接受了其他人在这里编写的另一个脚本的部分内容并试图将其修改为工作,但它只是通过电子邮件发送脚本中列出的第一个人,无论该单元格的内容是什么。此外,有时候单元格可能是空白的,不需要发送电子邮件。提前抱歉,我对此很新。
function send() {
//Sort entries so most recent is at top of spreadsheet and pause
getSpreadSheet();
Utilities.sleep(500);
//Declare global variables
var to;
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var eaddress = sheet.getRange('H2').getValue().toString();
// Determine who to email
if (eaddress = "User 1") {
to = "user1@company.com";
} else if (eaddress = "User 2") {
to = "user2@company.com";
} else if (eaddress = "User 3") {
to = "user3@company.com";
} else if (eaddress = "User 4") {
to = "user4@company.com";
}
// Email sent
var subject = 'Customer Complaint';
var body = 'A customer complaint form has been submitted and escalated to you'
MailApp.sendEmail(to, subject, body);
}
答案 0 :(得分:0)
char dictionary[] = "abcdefghijklmnopqrstuwxyz";
char *decode(unsigned int value, char *buff, int numofwrds, ...)
{
va_list vl;
int *fieldsizes = malloc(sizeof(int) * numofwrds);
int bitsize = 0;
char *result = NULL;
if (fieldsizes != NULL)
{
va_start(vl, numofwrds);
for (int i = 0; i < numofwrds; i++)
{
fieldsizes[i] = va_arg(vl, int);
bitsize += fieldsizes[i];
}
va_end(vl);
for (int i = 0; i < numofwrds; i++)
{
unsigned int mask, offset;
mask = (1 << fieldsizes[i]) - 1;
offset = bitsize - fieldsizes[i];
mask <<= offset;
buff[i] = dictionary[(value & mask) >> offset];
bitsize -= fieldsizes[i];
}
free(fieldsizes);
result = buff;
}
buff[numofwrds] = '\0';
return result;
}
答案 1 :(得分:0)
您的脚本中存在多个问题,但最明显的问题是使用赋值运算符&#39; =&#39;而不是&#39; ==&#39;和&#39; ===&#39;实际上用于比较值。使用&#39; if(x == y)&#39;或者&#39; if(x === y)&#39;如果你想避免JS中的类型推断。
在前一种情况下,如果您比较5(数字)和&#39; 5&#39;,请使用&#39; ==&#39;实际上会返回true,因为JS引擎会尝试将值带到同一类型。使用&#39; ===&#39;将进行比较,同时考虑变量类型。
您的脚本通过电子邮件向第一个人发送电子邮件,因为您将该电子邮件分配给脚本中的变量,并且无法比较任何内容。