ユーザーがエントリを作成できるようにするページフラグメントがあります。彼らは送信ボタンをクリックすると、それは次のように実行します:電子メールアドレス(またはユーザー名)を通知メールに含めようとしています
newSOEmailMessage(widget);
widget.datasource.createItem();
app.closeDialog();
これは、ウィジェットのフィールドの値が含まれ、ユーザーに電子メールを送り、クライアントスクリプトアクティブ:
function newSOEmailMessage(sendButton) {
var pageWidgets = sendButton.root.descendants;
var currentuser = Session.getActiveUser().getEmail();
var htmlbody = currentuser + 'has created new system order for: <h1><span style="color:#2196F3">' + pageWidgets.ShowName.value + ' - ' + pageWidgets.UsersPosition.value + '</h1>' +
'<p>R2 Order #: <b>' + pageWidgets.R2OrderNumber.value + '</b>' +
'<p>Delivery Date: <b>' + pageWidgets.DeliveryDate.value.toDateString() + '</b>' +
'<p>Start of Billing: <b>' + pageWidgets.SOB.value.toDateString() + '</b>' +
'<p>Sales Person: <b>' + pageWidgets.SalesPerson.value + '</b>' +
'<p> </p>' +
'<p>Company: <b>' + pageWidgets.Company.value + '</b>' +
'<p> </p>' +
'<p>Notes: <b>' + pageWidgets.Notes.value + '</b>';
google.script.run
.withSuccessHandler(function() {
})
.withFailureHandler(function(err) {
console.error(JSON.stringify(err));
})
.sendEmailCreate(
'[email protected]',
'New order for: ' + pageWidgets.ShowName.value + ' - ' + pageWidgets.UsersPosition.value,
htmlbody);
}
をこの作品のすべて"currentuser"オプション(var htmlbody =後)以外は問題ありません。
Session is not defined
at newSOEmailMessage (Notifications_ClientScripts:7:45)
at SystemOrders_Add.SubmitButton.onClick:1:1
私は電子メールアドレス(または好ましくは、ユーザーの実際の名前)を等しくなるように、「CurrentUserに」を希望:コードで、私は次のエラーを取得する上で。
例:私は何をしないのです
「ジョン・ドウがために...新しいシステム順序を作成しましたか」?
ありがとうございました!
注:別のモデルのコメントセクションにユーザーの名前を表示するためのディレクトリモデルのセットアップが既にあります。そのモデルは、以下を実行している(私は私のSystemOrdersモデルにそれを追加することができると仮定している?)
// onCreate
var email = Session.getActiveUser().getEmail();
var directoryQuery = app.models.Directory.newQuery();
directoryQuery.filters.PrimaryEmail._equals = email;
var reporter = directoryQuery.run()[0];
それはSession.getActiveUser()getEmail()と思われます;。 Apps Script(https://developers.google.com/apps-script/reference/base/session#getActiveUser())の一部であり、クライアントスクリプトで使用することはできません。クライアントスクリプトの場合、これを使用することができます:https://developers.google.com/appmaker/scripting/api/client#User – Wilmar