5 Replies Latest reply on May 16, 2017 8:09 AM by philmodjunk

    Avoiding repetitions in a  portal

    ruggero-chignoli

      A very simple question for the experts (but not for me)

       

      I have a Table (A) related to another Table (B) with a one to many relationship.

      In a form of Table A I would like to put a portal where the related records of Table B appear, avoiding any repetition.

       

      How do you do it ?

       

      Thanks for the help

        • 1. Re: Avoiding repetitions in a  portal
          philmodjunk

          Do you want to prevent the creation of records with duplicate values or just the display of records with duplicate values?

          • 2. Re: Avoiding repetitions in a  portal
            ruggero-chignoli

            I just want to display the record without duplicate values.

            • 3. Re: Avoiding repetitions in a  portal
              philmodjunk

              I will assume for the sake of these examples that you are preventing display of records with duplicate values in a single field.

               

              There are two methods that I know that still use a portal. There are other alternatives that dispense with using a portal altogether such as a Single field using ExecuteSQL to list the data that I will not describe in this particular post.

               

              a) Set up another table where the unique values have been eliminated. That would be a lot of work just to list unique values, but then, in many cases, such a table is useful in its own right as a tool for better managing the same data so it is an option to consider.

               

              b) Set up a self join between the portal's table occurrence and another occurrence of the same table. This method requires a primary key field in the portal's table that uniquely Identifies each record in that table.

               

              Say that you have this relationship to start:

               

              LayoutTableOccurrence::PrimaryKey = PortalTO::ForeignKey

               

              Duplicate the PortalTO occurrence and set up this relationship:

               

              PortalTO::foreignKey = PortalTODupFilter::foreignKey AND

              PortalTO::FieldWithDups = PortalTODupFilter::FieldWithDups

               

              Then use this portal filter expression to drop out duplicates:

               

              PortalTO::PrimaryKey = PortalTODupFilter::PrimaryKey

               

              How it works:

               

              All the Records in the Portal's table with the same ForeignKey and FieldWIthDups values will match to the same record in PortalTODupFilter. Only one of those will have the same PrimaryKey (being the very same record on both sides of the relationship) and thus only that one instance of that value appears in the portal.

              • 4. Re: Avoiding repetitions in a  portal
                ruggero-chignoli

                Thanks Phil

                 

                a little bit difficult to understand but I'll try your solution.

                 

                • 5. Re: Avoiding repetitions in a  portal
                  philmodjunk

                  Feel free to ask follow up questions on any part of that replay where things are not clear.