2 Replies Latest reply on Nov 9, 2010 8:05 AM by st3lla

    How to create a record in a layout with 2 related tables?

    st3lla

      Title

      How to create a record in a layout with 2 related tables?

      Post

      Hello everybody!

      I am working on a project which keeps history of women who visit their gynecologist. I have a layout, called "Main", which shows demographics of a specific woman (name, address, etc) and a summary of results of her medical examination.

      In this layout there is a button "New Cycle" that goes to the Layout "Cycle Details", which shows the demographics (table "woman") again and info about the cycle of the woman which means the procedure of IVF (table "cycle"). Here is the thing, one woman can have many cycles. When I press "New Cycle", I can make a record of cycle for a specific woman whose name is the same as in the Main layout. When I go back to the Main layout I have a portal with the fields of table "cycle" which has to get updated. However, if I want to add a new cycle then the button "New Cycle" from Layout "Cycle Details" allows me only to edit the previous record. If I press new record, then the couple demographics disappear and I have to make a totally new record; so the relationship between woman and cycle tables gets lost.

      So far, the table cycle (child-table) has a field "WomanID" which is related to the field "WomanID" of table woman (parent-table).

      Is there any way to update the table cycle of Cycle Details layout without changing the couple demographics? In that way I would like in the Main layout to see my portal get updated with more than just one cycle record.

      Any help would be much appreciated! Thanks in advance!

        • 1. Re: How to create a record in a layout with 2 related tables?
          philmodjunk

          If you display your records in portals with the allow creation of records via this relationship option enabled, you can create a new related record simply by entering data in the bottom blank row of the portal.

          Scripts to create records in related tables generally follow this pattern:

          Freeze window
          Set Variable [$ID ; //select primary key field of parent record]
          go To Layout [//specify layout to related child table]
          New Record/Request
          Set Field [ Childtable::foreignkeyfield ; $ID ]
          Go To Layout [original layout]

          You'll have to substitute your fields for the ones I used in the example.

          • 2. Re: How to create a record in a layout with 2 related tables?
            st3lla

            Sorry for the delay of my response.

            Well, I did what you said adjusting the script to my own fields. It worked and I wanted to thank you!

            Just a small notice, I replaced the last line of your script with this one "Go To Layout [Cycle Deails]", because I wanted to create a record in a different layout, just in case someone else tries it.

            Thanks again!