从 AppMaker 数据库生成电子邮件列表
Generating an email list from AppMaker Database
我想弄清楚如何获取涉及电子邮件列的数据库信息,用所有电子邮件创建一个数组,然后使用 "button" 功能填充 "To:" 部分电子邮件页面。
感谢任何帮助。在这方面非常新,并指出我从哪里获取信息会很棒。谢谢
我建议您 运行 一个服务器脚本来查询包含电子邮件的数据源。该脚本将如下所示:
function getEmails(){
var query = app.models.<yourmodel>.newQuery();
var results = query.run();
var allEmails = [];
if(results.length > 0){
for(var i = 0; i < results.length; i++){
var uniqueEmail = results[i].<emailfieldname>;
allEmails.push(uniqueEmail);
}
}
return allEmails.join();
}
然后将脚本添加到按钮小部件 "onclick" 事件,该事件将 运行 服务器脚本并处理返回的数据。类似于此:
function poulateToField(response){
<widget path>.text/value = response;
}
google.script.run.withSuccessHandler(poulateToField).getEmails();
上面的widget path就是"To:"widget的路径,可以是文本框,文本区域等。在我的例子中,我使用文本区域和路径是这样的“widget.parent.descendants.TextArea1.value”
希望对您有所帮助。如果您有更多问题,请告诉我! :)
P.D。请不要忘记查看 official documentation 以获得更好、更详细的解释。
您还可以使用投影从数据源中获取项目(电子邮件)列表。根据本文 https://developers.google.com/appmaker/ui/binding#projections:
Projections let you access properties from records in a datasource's
items list. Access projections with the ..projections.. option in the
advanced binding wizard, or use the projection operator .. in a
binding path. For example, for an Employees datasource with a name
property, @datasources.Employee.items..name returns a list of all
employees' names.
您可以查看 "Call Scripts" 指南,该指南向您展示了如何使用此处提供的 App Maker 发送电子邮件 https://developers.google.com/appmaker/tutorials/call-scripts/
要使用预测并遵循上述指南,在 "Create the UI" 下的 步骤 #2 中:为收件人添加一个文本框:
c。在 属性 编辑器中,无需向文本框小部件输入 "To" 值,您可以 select 绑定并将小部件绑定到遵循此路径的数据源投影:datasource > items > ..projections.. > Email(电子邮件所在的数据源字段的名称)
例如,投影将如下所示:@datasource.items..email
这会自动将数据源中可用的所有电子邮件绑定到文本框小部件。然后您可以完成指南,电子邮件将发送到您数据源中的所有电子邮件地址。希望这有帮助。
我想弄清楚如何获取涉及电子邮件列的数据库信息,用所有电子邮件创建一个数组,然后使用 "button" 功能填充 "To:" 部分电子邮件页面。
感谢任何帮助。在这方面非常新,并指出我从哪里获取信息会很棒。谢谢
我建议您 运行 一个服务器脚本来查询包含电子邮件的数据源。该脚本将如下所示:
function getEmails(){
var query = app.models.<yourmodel>.newQuery();
var results = query.run();
var allEmails = [];
if(results.length > 0){
for(var i = 0; i < results.length; i++){
var uniqueEmail = results[i].<emailfieldname>;
allEmails.push(uniqueEmail);
}
}
return allEmails.join();
}
然后将脚本添加到按钮小部件 "onclick" 事件,该事件将 运行 服务器脚本并处理返回的数据。类似于此:
function poulateToField(response){
<widget path>.text/value = response;
}
google.script.run.withSuccessHandler(poulateToField).getEmails();
上面的widget path就是"To:"widget的路径,可以是文本框,文本区域等。在我的例子中,我使用文本区域和路径是这样的“widget.parent.descendants.TextArea1.value”
希望对您有所帮助。如果您有更多问题,请告诉我! :)
P.D。请不要忘记查看 official documentation 以获得更好、更详细的解释。
您还可以使用投影从数据源中获取项目(电子邮件)列表。根据本文 https://developers.google.com/appmaker/ui/binding#projections:
Projections let you access properties from records in a datasource's items list. Access projections with the ..projections.. option in the advanced binding wizard, or use the projection operator .. in a binding path. For example, for an Employees datasource with a name property, @datasources.Employee.items..name returns a list of all employees' names.
您可以查看 "Call Scripts" 指南,该指南向您展示了如何使用此处提供的 App Maker 发送电子邮件 https://developers.google.com/appmaker/tutorials/call-scripts/
要使用预测并遵循上述指南,在 "Create the UI" 下的 步骤 #2 中:为收件人添加一个文本框:
c。在 属性 编辑器中,无需向文本框小部件输入 "To" 值,您可以 select 绑定并将小部件绑定到遵循此路径的数据源投影:datasource > items > ..projections.. > Email(电子邮件所在的数据源字段的名称)
例如,投影将如下所示:@datasource.items..email
这会自动将数据源中可用的所有电子邮件绑定到文本框小部件。然后您可以完成指南,电子邮件将发送到您数据源中的所有电子邮件地址。希望这有帮助。