私の仕事の一部を自動化しようとして、私はGoogleスクリプトの基礎を学び始めています。送信する必要があります複数の列とシートの通知
データが1つの列または別の列に入力されたときに電子メール通知を送信するスプレッドシートがあります。このスプレッドシートには2つのタブがあり、私はこれを起こしたいと思います。
スクリプトの現在の結果は、2回目の「sendnotification」機能のメールです。
質問:スクリプトで両方の機能を考慮するにはどうすればよいですか?
私はこのコードがより良い方法でIF機能を使用している可能性がありますが、私は迷っています。
一部のコンテキストでは、製造時に使用されます。生産はオフサイトの会社によって行われ、いずれかの用紙の10桁目に数量を入力すると、私はそれがグループの人々に私が仕事をする電子メールを送信したい。同様に、製品の品質テストが完了したら、私は12桁目に入力したいと思っていて、オフサイト会社に電子メールを送ります。
function sendNotification() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//Get Active cell
var mycell = ss.getActiveSelection();
var cellcol = mycell.getColumn();
var cellrow = mycell.getRow();
//Define Notification Details
var recipients = "[email protected]";
var subject = "Disc production was entered on the "+ss.getName();
var body = ss.getName() + " has been updated with an amount produced. Visit " + ss.getUrl() + " to view the quantities entered.";
//Check to see if column is A or B to trigger
if (cellcol == 10)
{
//Send the Email
MailApp.sendEmail(recipients, subject, body);
}
//End sendNotification
}
function sendNotification() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//Get Active cell
var mycell = ss.getActiveSelection();
var cellcol = mycell.getColumn();
var cellrow = mycell.getRow();
//Define Notification Details
var recipients = "[email protected]";
var subject = "A lot of disc has been RELEASED by XYZ Company";
var body = ss.getName() + " has been updated with a lot of disc that were released by XYZ Company. Visit " + ss.getUrl() + " to view this updated information.";
//Check to see if column is A or B to trigger
if (cellcol == 12)
{
//Send the Email
MailApp.sendEmail(recipients, subject, body);
}
//End sendNotification
}
わかりやすくするために、列10または列12に入力すると電子メールが自動的に送信されますか? 'onedit'トリガと同じですか? –
データがいずれかの列に入力されたときに自動的に電子メールが送信されます。 –