4 Replies Latest reply: Jan 23, 2013 9:03 AM by 986451 RSS

    Insert Multiple record into table while saving the form

    986451
      Dear Friends,

      Currently we have a custom form, which has a tabular form layout, when we input new record and click save, it inserts one record in to table. This form is based on database table.
      Now my requirement is to customize one column in this form i.e. for example column channel (channel may be A,B,C,D,E). I need to make this channel filed as a check box displaying A ,B,C,D,E. After i input the values in all fields and if i choose channel as A,B,D (check box checked for A, B AND D). Click save. i need 3 rows inserted in to db table. All same values in 3 rows excepts the channel column value in each shuld be A for 1st row, B for 2nd and D for 3rd row.

      How to achieve this? Need you suggestions to implement this.

      Thanks in Advance.
        • 1. Re: Insert Multiple record into table while saving the form
          MLBrown
          I believe if I was doing this, I would take your current setup and make that block a non-database block and just use it to gather my data for the "real" database block that I would not have displayed on the canvas. I would then add logic, either in the WHEN-CHECKBOX-CHANGED trigger or in a "Process" button if you had one that would contain the logic to loop through your non-database block and insert the appropriate number of records into the database block for each of the channels that was chosen.
          • 2. Re: Insert Multiple record into table while saving the form
            Andreas Weiden
            I would go the other way round. Create a database view which selects the data in the way you need it to display in your form.
            To handle the updates, create an INSTEAD-OF-trigger on the view which then does the necessary inserts into your tables.

            Base your block in forms on that view.
            You may have to change the Keymode to Non-updateable and maybe create your own ON-LOCK-trigger.

            This keeps your form simple and hides all the logic in the database.
            • 3. Re: Insert Multiple record into table while saving the form
              rgarim985970
              Hope this will fix your issue :
              Why don't u take something called a collection and collect all the relevant data once the apply/submit button is pressed and save that data in the table.
              Rather a simplified one than changing ur form structure. But the problem is selecting the exact kind of Collection

              Regards
              Ram
              • 4. Re: Insert Multiple record into table while saving the form
                986451
                Hi Ram,

                In case of using collections, do we have to change the current form structure i.e. current block is based on database table (there is no desperate logic to insert).
                Can you guide me how to proceed by using collection?