How to update records in related data models in Google App Maker












0















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?










share|improve this question























  • 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


















0















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?










share|improve this question























  • 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
















0












0








0








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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





















  • 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














1 Answer
1






active

oldest

votes


















0














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.






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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.






    share|improve this answer




























      0














      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.






      share|improve this answer


























        0












        0








        0







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 27 '18 at 14:57









        Markus MalessaMarkus Malessa

        74649




        74649
































            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks