4 Replies Latest reply on Sep 3, 2013 2:08 PM by SimonSherwood_1

    Filtering to show only last records in a Portal

    SimonSherwood_1

      Title

      Filtering to show only last records in a Portal

      Post

           Hi

           Does anyone know a way that I can filter to show only the last records in a portal.  I have a database where the Parent table creates records in the child (portal) table on a regular basis, however only the most recent are really relevant. Data is also entered into the Portal so eventually it's going to be a bit of a bind scrolling through the portal to get to the bottom. The records have both id (serial number) and date fields but all of my calculations seem to fail.

           I thought date field+365>get(currentdate) would show what I wanted but it still shows all.

           Simon.

        • 1. Re: Filtering to show only last records in a Portal
          philmodjunk

               Why not specify a sort order that lists the most recently created records at the top of the portal? Then use a button and a script to create a new blank record at the top of the portal instead of just entering the data in the bottom blank add row.

          • 2. Re: Filtering to show only last records in a Portal
            SimonSherwood_1

                 I didn't know that you could make  script to add the portal row to the top, I'll have a look at that.  I have a button to go to the portal, trouble is I have to portals on the form and sometimes the button goes to the other portal, but not all the time.

                 Simon.

            • 3. Re: Filtering to show only last records in a Portal
              philmodjunk

                   The script doesn't actually add it to the top. It adds a new related record and then the specified portal sort order puts it at the top of the portal.

                   

                         I have a button to go to the portal, trouble is I have to portals on the form and sometimes the button goes to the other portal, but not all the time.

                   Sounds like you are using go to portal row without first using go to object to place the focus on the correct portal. (You use the name box in the inspector to assign object names to each portal.) This is one of the reasons I avoid the use of Go to Portal Row when it is possible to do so and it is possible in this case:

                   Say you have these tables, layouts, relationships:

                   LayoutTable::PrimaryKey = PortalTable::ForeignKey

                   This script creates a new record in the portal:

                   Set Variable [ $ID ; value: LayoutTable::PrimaryKey ]
                   Go to Layout ["PortalTable" (PortalTable) ]
                   New Record/Request
                   Set Field [PortalTable::ForeignKey ; $ID ]
                   Go to Layout [Original Layout]

                   If you have a sort order specified for the portal that puts the most newly created record first, the record created by this script will appear at the top of the portal.

              • 4. Re: Filtering to show only last records in a Portal
                SimonSherwood_1

                     Thanks, it works well.  I didn't realise you could name objects, I'm learning all the time at the moment.

                      

                     Simon.