首页 文章

Google App Maker - 基于来自其他数据源的电子邮件的目录信息

提问于
浏览
-1

在我正在从Google表格中获取用户电子邮件地址的应用程序上工作 .

我想使用该电子邮件地址来显示目录中的全名和缩略图照片 .

Screenshot of the UI - 隐藏电子邮件和名称以保护用户数据

到目前为止,当我尝试链接这两个时,我从目录中获取所有用户的第一张照片 .

任何想法如何链接两者,因为目录不支持添加新的关系?

2 回答

  • 1
    • 创建一个新的计算模型

    • 在“数据源”选项卡的“服务器脚本”中,添加以下代码 .

    • Be sure to correct the Model and Field names to match yours!

    .

    //Get the Spreadsheet Data
    var spreadsheetData = app.models.MySpreadsheetSource.newQuery().run();
    var combinedData = []; // Place to store output for calculated model
    spreadsheetData.forEach(function(record){ //iterate the ss data
      var query = app.models.Directory.newQuery(); //start a query for directory
      query.filters.PrimaryEmail._equals = record.email; //set the query for the email
      var dirRecord = query.run()[0]; //get the one record
    
      //make a new record for the calculated model
      var newRecord = app.models.Directory_Spreadsheet.newRecord(); 
      //add the data from both SS and Directory models
      newRecord.Email = record.email; //from ss
      newRecord.address = record.address;
      newRecord.Full_Name = dirRecord.FullName; //from Directory
      newRecord.Thumbnail = dirRecord.ThumbnailPhotoUrl;
      //Add More Fields
    
      combinedData.push(newRecord); //add to output
    });
    return combinedData; //return the combine object
    

    您可以在Accordion中使用此数据源来显示组合数据 .

  • 0

    如果您只是显示一条记录,则可以从电子表格中获取电子邮件,然后执行此类操作 .

    将数据源设置为“目录”和“标签”窗口小部件的页面或面板与文本字段绑定到要显示的字段 .

    enter image description here

    enter image description here

    从电子表格收到电子邮件后,假设您将其返回到客户端,请使用:

    app.datasources.Directory.query.filters.PrimaryEmail._equals = emailFromSpreadsheet;
    app.datasources.Directory.load();
    

相关问题