3 Replies Latest reply on Jan 25, 2011 12:01 PM by philmodjunk

    Portals with children next to portals whith grandchildren

    wladdy

      Title

      Portals with children next to portals whith grandchildren

      Post

      I have a database with three tables: 'Days', 'Shows' to record performances given on various days and 'Acts' to record the various acts making up each performance. There is a one-to-many relationship from Days to Shows and another one-to-many relationship between Shows and Acts.

      I need a single layout in which I could:

      1) enter a new Show without manually specifying the primary key of the corresponding Day

      2) enter a new Act without manually specifying the primary key of the corresponding Show

      So I created a ‘Data entry’ layout showing records from ‘Days’. In it, I added a portal (A) showing related records from ‘Shows’. This satisfies requirement 1.

      To satisfy requirement 2, I created in ‘Data entry’ another portal (B) showing related records from ‘Acts’. In the filtering options of that portal, I specified that the foreign key of an Act be equal to the primary of a Show.

      I was hoping that a new record in portal A would automatically show corresponding records in portal B and, more importantly, make B add the right primary key to any new record added within it. Unfortunately, whatever I select in A, all records that I enter in B have the same foreign key, which is the primary key of the first record in A.

      Any help to solve this situation would be greatly appreciated.  W.

        • 1. Re: Portals with children next to portals whith grandchildren
          Abhaya

          Hello Wladdy,

          Make  a relation bet'n Show and Actwith constant field value =1

          From that relation bring the portal B in the data entry layout.

          I hope it'll work

          • 2. Re: Portals with children next to portals whith grandchildren
            Sorbsbuster

            "1) enter a new Show without manually specifying the primary key of the  corresponding Day"

            - is that not what would happen if you simply specified the relationship as 'Allow creation of new records" in the child table, with no need for the special arrangements of the data entry screen?

            • 3. Re: Portals with children next to portals whith grandchildren
              philmodjunk

              Seems to me, that you've got a basic interface design issue you need to resolve first.

              If you are on a given day record, that allows your "Shows" portal to work as all records in it will have the same primary key value from "Days". But the "Acts" records could be linked to any one of the "Shows" records that you enter in the "Shows" records.

              Looks like you need a script to set up and maintain a link from Days to Acts that will correctly enter the correct "Shows" primary key.

              Define this additional relationship, just for the "Acts" portal:

              Days::gCurrentShowID = SelectedShow_Acts::ShowID

              gCurrentShowID is a global field and SelectedShow_Acts would be a new table occurrence of Acts. (In Manage | Database | Relationships, click Acts to select it, then click the button with two green plus signs.) "Allow creation of records..." should be enabled for SelectedShow_Acts in this relationship.

              In the Shows portal, you'd set up script trigger(s) to run this script:
              Set Field [Days::gCurrentShowID ; Shows::ShowID]
              Commit Record

              Setting up an OnObjectExit script on the Shows portal should work here but I haven't tested this.

              This way, any time you edit/create a record in the Shows portal, the portal to SelectedShow_Acts should update to display any Acts for that show and entering data into it, should automatically link it to the most recently edited record in the Shows portal. (Conditional formatting can be used to make the "current show" portal row a different color to help the user keep track of which show's Acts are visible.)