How to update records in related data models in Google App Maker
I’m creating an app with two data models:
1/ Model “A” with fields: Id, DATE, STATUS, EMAIL_ADDRESS, CASE_TYPE, CASE_DESCRIPTION.
2/ Model “B” with another fields (Id, DATE, ADMIN_EMAIL, CASE_RESOLUTION, and no field called STATUS).
Models”A” and “B” are related ONE-ONE (“A” is the Owner).
Users fill two forms. First form creates record in model “A”, and the second one: in model “B”.
When saving form number one I’m setting record.STATUS = “NEW” automatically, using event onBeforeCreate.
I’d like to update the STATUS to “BOSS_ACCEPT” in model “A” after saving form number two (datasource: “A”: “B” (related)). What should I do?
google-app-maker
add a comment |
I’m creating an app with two data models:
1/ Model “A” with fields: Id, DATE, STATUS, EMAIL_ADDRESS, CASE_TYPE, CASE_DESCRIPTION.
2/ Model “B” with another fields (Id, DATE, ADMIN_EMAIL, CASE_RESOLUTION, and no field called STATUS).
Models”A” and “B” are related ONE-ONE (“A” is the Owner).
Users fill two forms. First form creates record in model “A”, and the second one: in model “B”.
When saving form number one I’m setting record.STATUS = “NEW” automatically, using event onBeforeCreate.
I’d like to update the STATUS to “BOSS_ACCEPT” in model “A” after saving form number two (datasource: “A”: “B” (related)). What should I do?
google-app-maker
How is your form for model B set up? Is the datasource 'Model_B (create) or is it 'Model_A: Model_B (relation) (create)? If it is the first option how are you setting the relation to Model_A? Because if you set the form for Model_B the second way, it automatically selects your current selected record in Model_A as your relation.
– Markus Malessa
Nov 26 '18 at 20:04
Thank for the answer. Actually, model B i set in the second way. I've already tried add record.modelA.STATUS = "BOSS_ACCEPT" onBeforeCreate and it didn't work. Maybe I'm doing something wrong? Is there any other way to change the STATUS in model A?
– Jolanta
Nov 27 '18 at 9:45
add a comment |
I’m creating an app with two data models:
1/ Model “A” with fields: Id, DATE, STATUS, EMAIL_ADDRESS, CASE_TYPE, CASE_DESCRIPTION.
2/ Model “B” with another fields (Id, DATE, ADMIN_EMAIL, CASE_RESOLUTION, and no field called STATUS).
Models”A” and “B” are related ONE-ONE (“A” is the Owner).
Users fill two forms. First form creates record in model “A”, and the second one: in model “B”.
When saving form number one I’m setting record.STATUS = “NEW” automatically, using event onBeforeCreate.
I’d like to update the STATUS to “BOSS_ACCEPT” in model “A” after saving form number two (datasource: “A”: “B” (related)). What should I do?
google-app-maker
I’m creating an app with two data models:
1/ Model “A” with fields: Id, DATE, STATUS, EMAIL_ADDRESS, CASE_TYPE, CASE_DESCRIPTION.
2/ Model “B” with another fields (Id, DATE, ADMIN_EMAIL, CASE_RESOLUTION, and no field called STATUS).
Models”A” and “B” are related ONE-ONE (“A” is the Owner).
Users fill two forms. First form creates record in model “A”, and the second one: in model “B”.
When saving form number one I’m setting record.STATUS = “NEW” automatically, using event onBeforeCreate.
I’d like to update the STATUS to “BOSS_ACCEPT” in model “A” after saving form number two (datasource: “A”: “B” (related)). What should I do?
google-app-maker
google-app-maker
asked Nov 26 '18 at 18:37
JolantaJolanta
41
41
How is your form for model B set up? Is the datasource 'Model_B (create) or is it 'Model_A: Model_B (relation) (create)? If it is the first option how are you setting the relation to Model_A? Because if you set the form for Model_B the second way, it automatically selects your current selected record in Model_A as your relation.
– Markus Malessa
Nov 26 '18 at 20:04
Thank for the answer. Actually, model B i set in the second way. I've already tried add record.modelA.STATUS = "BOSS_ACCEPT" onBeforeCreate and it didn't work. Maybe I'm doing something wrong? Is there any other way to change the STATUS in model A?
– Jolanta
Nov 27 '18 at 9:45
add a comment |
How is your form for model B set up? Is the datasource 'Model_B (create) or is it 'Model_A: Model_B (relation) (create)? If it is the first option how are you setting the relation to Model_A? Because if you set the form for Model_B the second way, it automatically selects your current selected record in Model_A as your relation.
– Markus Malessa
Nov 26 '18 at 20:04
Thank for the answer. Actually, model B i set in the second way. I've already tried add record.modelA.STATUS = "BOSS_ACCEPT" onBeforeCreate and it didn't work. Maybe I'm doing something wrong? Is there any other way to change the STATUS in model A?
– Jolanta
Nov 27 '18 at 9:45
How is your form for model B set up? Is the datasource 'Model_B (create) or is it 'Model_A: Model_B (relation) (create)? If it is the first option how are you setting the relation to Model_A? Because if you set the form for Model_B the second way, it automatically selects your current selected record in Model_A as your relation.
– Markus Malessa
Nov 26 '18 at 20:04
How is your form for model B set up? Is the datasource 'Model_B (create) or is it 'Model_A: Model_B (relation) (create)? If it is the first option how are you setting the relation to Model_A? Because if you set the form for Model_B the second way, it automatically selects your current selected record in Model_A as your relation.
– Markus Malessa
Nov 26 '18 at 20:04
Thank for the answer. Actually, model B i set in the second way. I've already tried add record.modelA.STATUS = "BOSS_ACCEPT" onBeforeCreate and it didn't work. Maybe I'm doing something wrong? Is there any other way to change the STATUS in model A?
– Jolanta
Nov 27 '18 at 9:45
Thank for the answer. Actually, model B i set in the second way. I've already tried add record.modelA.STATUS = "BOSS_ACCEPT" onBeforeCreate and it didn't work. Maybe I'm doing something wrong? Is there any other way to change the STATUS in model A?
– Jolanta
Nov 27 '18 at 9:45
add a comment |
1 Answer
1
active
oldest
votes
There are really two ways to handle updating your related Model A record after creating your Model B record.
Server Side, which is more secure.
You would need the following in your OnAfterCreate server event script in Model B:
var relatedrecord = app.models.Model_A.getRecord(record.Model_A._key);
relatedrecord.STATUS = "BOSS_ACCEPT";
app.saveRecords([relatedrecord]);
And in order to reflect this change on the client, you would need to include a datasource load in your 'Submit' button createItem() call back function. This would look something like this:
widget.datasource.createItem(function() {
app.datasources.Model_A.load();
});
Client Side solution.
In your Form 2 'Submit' button include the following code:
widget.datasource.createItem(function(record) {
record.Model_A.STATUS = 'BOSS_ACCEPT';
});
If this answer helps you please mark it as accepted. Thank you.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53487133%2fhow-to-update-records-in-related-data-models-in-google-app-maker%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are really two ways to handle updating your related Model A record after creating your Model B record.
Server Side, which is more secure.
You would need the following in your OnAfterCreate server event script in Model B:
var relatedrecord = app.models.Model_A.getRecord(record.Model_A._key);
relatedrecord.STATUS = "BOSS_ACCEPT";
app.saveRecords([relatedrecord]);
And in order to reflect this change on the client, you would need to include a datasource load in your 'Submit' button createItem() call back function. This would look something like this:
widget.datasource.createItem(function() {
app.datasources.Model_A.load();
});
Client Side solution.
In your Form 2 'Submit' button include the following code:
widget.datasource.createItem(function(record) {
record.Model_A.STATUS = 'BOSS_ACCEPT';
});
If this answer helps you please mark it as accepted. Thank you.
add a comment |
There are really two ways to handle updating your related Model A record after creating your Model B record.
Server Side, which is more secure.
You would need the following in your OnAfterCreate server event script in Model B:
var relatedrecord = app.models.Model_A.getRecord(record.Model_A._key);
relatedrecord.STATUS = "BOSS_ACCEPT";
app.saveRecords([relatedrecord]);
And in order to reflect this change on the client, you would need to include a datasource load in your 'Submit' button createItem() call back function. This would look something like this:
widget.datasource.createItem(function() {
app.datasources.Model_A.load();
});
Client Side solution.
In your Form 2 'Submit' button include the following code:
widget.datasource.createItem(function(record) {
record.Model_A.STATUS = 'BOSS_ACCEPT';
});
If this answer helps you please mark it as accepted. Thank you.
add a comment |
There are really two ways to handle updating your related Model A record after creating your Model B record.
Server Side, which is more secure.
You would need the following in your OnAfterCreate server event script in Model B:
var relatedrecord = app.models.Model_A.getRecord(record.Model_A._key);
relatedrecord.STATUS = "BOSS_ACCEPT";
app.saveRecords([relatedrecord]);
And in order to reflect this change on the client, you would need to include a datasource load in your 'Submit' button createItem() call back function. This would look something like this:
widget.datasource.createItem(function() {
app.datasources.Model_A.load();
});
Client Side solution.
In your Form 2 'Submit' button include the following code:
widget.datasource.createItem(function(record) {
record.Model_A.STATUS = 'BOSS_ACCEPT';
});
If this answer helps you please mark it as accepted. Thank you.
There are really two ways to handle updating your related Model A record after creating your Model B record.
Server Side, which is more secure.
You would need the following in your OnAfterCreate server event script in Model B:
var relatedrecord = app.models.Model_A.getRecord(record.Model_A._key);
relatedrecord.STATUS = "BOSS_ACCEPT";
app.saveRecords([relatedrecord]);
And in order to reflect this change on the client, you would need to include a datasource load in your 'Submit' button createItem() call back function. This would look something like this:
widget.datasource.createItem(function() {
app.datasources.Model_A.load();
});
Client Side solution.
In your Form 2 'Submit' button include the following code:
widget.datasource.createItem(function(record) {
record.Model_A.STATUS = 'BOSS_ACCEPT';
});
If this answer helps you please mark it as accepted. Thank you.
answered Nov 27 '18 at 14:57
Markus MalessaMarkus Malessa
74649
74649
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53487133%2fhow-to-update-records-in-related-data-models-in-google-app-maker%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How is your form for model B set up? Is the datasource 'Model_B (create) or is it 'Model_A: Model_B (relation) (create)? If it is the first option how are you setting the relation to Model_A? Because if you set the form for Model_B the second way, it automatically selects your current selected record in Model_A as your relation.
– Markus Malessa
Nov 26 '18 at 20:04
Thank for the answer. Actually, model B i set in the second way. I've already tried add record.modelA.STATUS = "BOSS_ACCEPT" onBeforeCreate and it didn't work. Maybe I'm doing something wrong? Is there any other way to change the STATUS in model A?
– Jolanta
Nov 27 '18 at 9:45