11 Replies Latest reply on Aug 16, 2011 11:57 AM by JessicaFiorini

    Duplicate Records From Portal Row Creation

    JessicaFiorini

      Title

      Duplicate Records From Portal Row Creation

      Post

      Hello,

      I am working on a database that creates a usage history for specific educational lessons. Lessons have a certain amount of changeable information dependent on the season. I have a file usage history table with items in a portal list under a tab in the Lesson Information Table. The file usage history is tied to the Lesson Information table by Lesson ID serial, auto-created, non-modifiable number. I have no problem creating a history on the file usage table but when I attempt to create a new history directly in the tabbed portal list section of the Lesson Information table, it creates two records for every one history input.

      I am using the following script attached to a "New History" button to create the new record / portal row:

      Freeze Window

      Go to Fiel [Seasons::Year]

      Go to Portal Row [Last]

      I am using the same script successfully in a similarily set up tasks history tab. Any suggestions?

      Thanks!

        • 1. Re: Duplicate Records From Portal Row Creation
          rjlevesque

          What is your table structure and relationships?

          • 2. Re: Duplicate Records From Portal Row Creation
            philmodjunk

            If "Allow creation of records..." is enabled for this portal's relationship as it seems, why do you need a script? You can simply type data into this bottom portal row to create the new related record.

            I try to avoid interacting with portals like this if at all possible. Scripts to do so are vulnerable to breaking should someone alter the layout design in the future.

            Try this script instead:

            Freeze Window
            Set Variable [$Key ; value: ParentTable::PrimaryKeyField ]
            go to layout [layout to portal's table]
            New Record/request
            Set Field [Portaltable::ForeignKeyField ; $Key ]
            go To layout [original layout]

            Note: PrimaryKeyField and ForeignKeyField should be the two fields used to define the relationship used for the portal.

            • 3. Re: Duplicate Records From Portal Row Creation
              JessicaFiorini

              Thanks Phil. I'll give it a go.

              • 4. Re: Duplicate Records From Portal Row Creation
                JessicaFiorini

                The script sorta works. It does bring me to the correct layout and set the $Key value but some odd behaviours have occured. Not only does it fill in the Lesson ID but it automatically fills in other fields with incorrect or non-applicable values, which I feel it should not. Also, every time I make a new record, a record line and an extra portal line are created. The extra portal row also fills in values that should not be there. Should I not have both sides of the portal relationship be able to create new records from the relationship? Could that be it?

                • 5. Re: Duplicate Records From Portal Row Creation
                  JessicaFiorini

                  Furthermore, I notice that the the extra portal rows get filled in with the first record information, whatever I try. Furthermore, if I go to the related record and return, there are about three identical portal rows.

                  • 6. Re: Duplicate Records From Portal Row Creation
                    philmodjunk

                    You need to describe the relationships involved here. Are there fields in the portal row that were selected from other table occurrences than the one named in Portal Setup's Show Records From drop down? If so, how are their table(s) related to the portal's table?

                    Are they calculation fields or fields that use "Looked up value" to refer to data in another table?

                    The extra bottom row is probably due to "allow creation of records via this relationship" being enabled in the relationship on which this portal is based. It is a check box you can select or clear in manage | Database | relationships when you double click the line linking these two tables. This feature adds a blank "add" row to the bottom of your existing records where you can create a new related record simply by entering data into this blank portal row.

                    • 7. Re: Duplicate Records From Portal Row Creation
                      JessicaFiorini

                      Thanks for the response.

                      There are two different tables being called in the portal row. The relationships are as follows:

                      Seasons::Season_ID=FileUsage::Season_ID with the "allow creation of records..." clicked on the Seasons side

                      FileUsage::Lesson_ID=Lesson::Lesson_ID with the "allow creation of records..." clicked on the File Usage side

                      The portal appears on the Lesson table.

                       

                      The problem is that when it creates an extra row, it automatically fills in some of the fields with info from the top row. Then when I click into other rows, it replaces any unique information with the information from the top row.

                      • 8. Re: Duplicate Records From Portal Row Creation
                        philmodjunk

                        "The portal appears on the Lesson table"

                        Please confirm that in layout setup... you see "Lesson" in the "show records from" drop down. This would indicate that the portal is located on a layout that is based on the Lesson Table Occurrence.

                        Then open portal setup and tell me exactly what text you see in "show Records from" in this dialog. (This will tell me on which table occurrence the portal is based.)

                        In layout mode, click each field and check the name shown in "display data from" in the top of the Inspector's data tab. If the part of name to the left of the :: doesn't exactly match the name in Portal Setup's "show Records from", it might explain the behavior you are seeing.

                        Any time you add a field to a portal from a different table occurence (Table occurrences are the "boxes" connected by relationship lines in Manage | Database | Relationships), the relationship between the portal row's table and that other table occurrence determine what data will appear in that field.

                        • 9. Re: Duplicate Records From Portal Row Creation
                          JessicaFiorini

                          Quick question: Which layout should I check for the "Lesson" in the "show records from" drop down?  Lesson or File Usage? All three?

                          • 10. Re: Duplicate Records From Portal Row Creation
                            philmodjunk

                            The layout where you have the portal. So far as I know, this is the only layout we are discussing here.

                            • 11. Re: Duplicate Records From Portal Row Creation
                              JessicaFiorini

                              OK. I changed the portal setup's "show records from" to File Usage and it worked. Thanks!