简体   繁体   English

google app maker相关记录的链接字段

[英]google app maker link fields of related records

I am attempting to set a field in one data model to equal to a field in a related data model. 我试图将一个数据模型中的字段设置为等于相关数据模型中的字段。 I've considered setting up an event to set the field equal to the other but do not know what the best trigger for this event would be and do not know the code that would be required. 我已经考虑过设置一个事件以将字段设置为与其他字段相等,但不知道此事件的最佳触发器是什么,也不知道所需的代码。

Additionally, perhaps an event is not needed and there is some more fundamental/basic way to establish this field connection between related models. 另外,也许不需要事件,并且有一些更基本的/基本的方法可以在相关模型之间建立这种现场联系。

Example: People Model has Companies Model as a related model. 示例:人员模型具有公司模型作为相关模型。 When adding a new People record, selecting the related Companies record would mean that the "Industry" field in the People record would be equal to the "Industry" field in the related Companies record. 在添加新的人员记录时,选择相关的公司记录将意味着人员记录中的“行业”字段将与相关公司记录中的“行业”字段相等。

Thank you! 谢谢!

You can execute a callback function after the People record is created. 创建人员记录后,可以执行回调函数。 The callback function would change the Industry field value of the related Companies record to match the same value of the People record. 回调函数将更改相关公司记录的“ 行业”字段值,以匹配“ 人员”记录的相同值。 Something like this ( GIF ). 像这样的东西( GIF )。 Notice that I am updating the Companies Industry value while creating a People record. 请注意,我在创建人员记录时正在更新“ 公司行业”价值。

Here's the code on a Client Script: 这是客户端脚本上的代码:

var pgPeople = app.pages.PeopleCompanies;
var pgPeopleDesc = pgPeople.descendants;

function updateRelatedRecordField(){

      var peopleDatasource = app.datasources.People;

      peopleDatasource.createItem(function(record){

        var industry = record.Industry;
        record.Companies.Industry = industry;

      });

}

You need to replace the default onClick function on the Form widget button with your function updateRelatedRecordField(); 您需要使用函数updateRelatedRecordField();替换“表单”小部件按钮上的默认onClick函数updateRelatedRecordField();

Read more here . 在这里阅读更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM