3 Replies Latest reply on Feb 23, 2012 9:45 AM by philmodjunk

    New Record with Multiple Portals on Layout

    ShariFoucher

      Title

      New Record with Multiple Portals on Layout

      Post

      Still working on dog licensing.  Have layout with main table as owner, portals as dog registration and dog license.  I want to be able to pull up an owner that has 1 or more dogs registered, and add a new one.

      I have a dog id on the registration that has auto-entry and works correctly in the portal for a new dog (generate on creation).  However, although the new license id correctly generates in the portal (also generate on creation), the link between these two tables is the new dog id, and what it is linking to is the first dog id in the registration portal.

      I have tried several different fields with a script trigger to go to the last portal row and make dog reg dog id = dog license dog id, but nothing seems to be working. 

        • 1. Re: New Record with Multiple Portals on Layout
          philmodjunk

          Are these your relationships?

          DogLicense>------Owner-----<DogRegistration

          With portals to DogLicense and DogRegistration on the Owner layout?

          Can one dog have more than one DogLicense Record?

          Can one dog have more than one Registration Record?

          • 2. Re: New Record with Multiple Portals on Layout
            ShariFoucher

            Owner ---> Dog Registration ---> Dog License

            Owner to Dog Registration via Owner ID, Dog Registration to Dog License via Dog ID

            There is no direct relationship between owner and dog license

            Yes, portals to Dog Registration first, then Dog License on Owner Layout

            There should only be one dog registration and one dog license per dog

            • 3. Re: New Record with Multiple Portals on Layout
              philmodjunk

              If there is only one dog registration and one dog license for a given dog. (You aren't storing historical records about a given dog...), then one option is to define a single table with fields for both license and registration info. A dog that is registered but not licensed would have empty fields in the licensing fields. Then a single portal with fields for each or two portals to the same table, but with different sets of fields may be placed on your layout and you won't have any issues linking the two as they are now the same record.

              Using your existing setup can be made to work with a script to create new records in the license table. If you wrote a script to go to the last portal row, you'd need to do two things: Give each portal an object name and use Go to Object ["NameofRegistrationportalHere"] to put the focus on the correct portal each time the script runs. Then you'd need to use go to portal row [last], followed by go to portal row [previous] to go to the next to last portal row if you've enabled "allow creation of records via this relationship" for the registration portal.

              I'd suggest not trying to interact with the portal directly like that. This script does the same thing more simply and is less vulnerable to future changes to the layout interfering with the script:

              Freeze Window
              If [ Not IsEmpty ( DogRegistration::OwnerID ) //make sure there's at least one registration record in portal ]
                 Go To Related Record [Show only related records; From table: DogRegistration; Using layout: "DogRegistration" (DogRegistration)]
                 Go To Record/request/page [last]
                 Set variable [$RegID ; DogRegistration::RegistrationID ]
                 Go to Layout [DogLicense]
                 New Record/Request
                 Set Field [DogLicense::RegistrationID ; $RegID]
                 Go to layout [original layout]
              End If