私はお詫び申し上げます。私はこれが新人質問で、簡単な答えであると確信しています。電子メール通知スクリプトで "null"フィールドのエラー
したがって、ユーザーがエントリを作成したときに電子メール通知を送信するには、次の方法を使用します。 "null"(空白)のエントリに関連する2つの動作を除いて、すべて正常に動作します。
function newSalesEmailMessage(sendButton) {
var pageWidgets = sendButton.root.descendants;
var fullName = app.datasources.CurrentUser.item.FullName;
var htmlbody = '<b><font size="3">' + fullName + '</font></b>' + ' has created a new sales entry for: ' +
'<h1><span style="color:#2196F3">' + pageWidgets.ShowName.value + '</h1>' +
'<p>Shoot Date: <b>' + pageWidgets.ProjectDate.value.toDateString() + '</b>' +
'<p>Contact: <b>' + pageWidgets.Contact.value + '</b>' +
'<p>Post AP: <b>' + pageWidgets.PostAP.value + '</b>' +
'<p>Sales Person: <b>' + pageWidgets.SalesPerson.value + '</b>' +
'<p>Notes: <b>' + pageWidgets.Notes.value + '</b>';
google.script.run
.withSuccessHandler(function() {
})
.withFailureHandler(function(err) {
console.error(JSON.stringify(err));
})
.sendEmailCreate(
'[email protected]',
'New Sales Entry for: ' + pageWidgets.ShowName.value,
htmlbody);
return sendButton === "" || sendButton === null || sendButton === undefined;
}
問題1:ユーザーがフィールドを空白のままにするたびにメールは理にかなっている、フィールドに「ヌル」を置きますが、人々は私を求め続ける「ナルは誰?」ああ。
"null"の代わりに空白(例: "")を出力する方法があれば、それは素晴らしいでしょう。
問題2:ユーザーがProjectDate(日付フィールド)を空白にすると、次のエラーが表示されます。nullのプロパティ 'toDateString'を読み取ることができません。
これは意味がありますが、明らかにこれによりこのスクリプトは完了しません。このようなもので両方の問題を解決できると期待していましたが、そうではありませんでした。
function newSalesEmailMessage(sendButton) {
var pageWidgets = sendButton.root.descendants;
if (pageWidgets === null) {
pageWidgets = "";
}
var fullName = app.datasources.CurrentUser.item.FullName;
var htmlbody = '<b><font size="3">' + fullName + '</font></b>' + ' has created a new sales entry for: ' +
'<h1><span style="color:#2196F3">' + pageWidgets.ShowName.value + '</h1>' +
'<p>Shoot Date: <b>' + pageWidgets.ProjectDate.value.toDateString() + '</b>' +
'<p>Contact: <b>' + pageWidgets.Contact.value + '</b>' +
'<p>Post AP: <b>' + pageWidgets.PostAP.value + '</b>' +
'<p>Sales Person: <b>' + pageWidgets.SalesPerson.value + '</b>' +
'<p>Notes: <b>' + pageWidgets.Notes.value + '</b>';
google.script.run
.withSuccessHandler(function() {
})
.withFailureHandler(function(err) {
console.error(JSON.stringify(err));
})
.sendEmailCreate(
'[email protected]',
'New Sales Entry for: ' + pageWidgets.ShowName.value,
htmlbody);
}
ありがとうございました。
これは機能しました。どうもありがとうございました。 –