13 Replies Latest reply on Sep 17, 2013 9:32 AM by philmodjunk

    New portal record at top of portal

    JohhnyHilly

      Title

      New portal record at top of portal

      Post

           I have a portal that is sorted in descending order by a date field (so most recent at the top). When a new portal record is created, it appears at the bottom then once committed it goes to the top based on it's date. I don't want to scroll down to the bottom of the portal every time a new portal record is created.

           How can I have it so instead of appearing at the bottom, the empty fields appear at the top of the portal. I tried this method (bottom of the page) http://forums.filemaker.com/posts/9c5a991a3a, but the new record is still at the bottom of the portal while the current field is the one at the top.

           Anyone know how to make this work? Thanks is advance.

        • 2. Re: New portal record at top of portal
          JohhnyHilly

               Tried that one already.  I have the same issue of it changing a record as one of the respondants in the thread. Is there no way to have the new entry at the top of the portal?

          • 3. Re: New portal record at top of portal
            SteveMartino

                 Here's what I did on my database.  Ugly but I'm the only one using it.  What I needed to do was to come off the last field I enter data into, and into a new portal row at the top.  Set the first field in the portal with the date (from another field) and put me into the second field in the portal 

                 It's fires from the last field I enter data into with an OnObjectExit Script trigger.  The main drawback is if you Shift Tab back out of the portal it will create another row. 

                 Mr Raybaudi just might puke when he sees it :)

                  

            • 4. Re: New portal record at top of portal
              philmodjunk

                   Just use:

                   Freeze Window
                   Set Variable [$ID ; YourParentTable::PrimaryKey ]
                   Go layout ["PortalTable" ( PortalTable ) ]
                   New Record/Request
                   Set Field [PortalTable::ForeignKey ; $ID ]
                   Go to Layout [original layout]

                   But look out for script triggers getting tripped by the change in layouts. You may need to make changes to any such trigger performed scripts so that you can disable them by setting a global variable.

              • 5. Re: New portal record at top of portal
                JohhnyHilly

                     Phil, how does this place a portal new record (while entering data) at the top of the portal as opposed to at the bottom of the portal?

                • 6. Re: New portal record at top of portal
                  philmodjunk

                       It doesn't on it's own. It just creates a new related record. BUT if you have specified a sort order for the portal or it's underlying relationship that lists the newest record first, that new record will automatically appear at the top of the portal. Sorting in descending order on an auto-entered serial number is probably the simplest way to produce such an order for your portal--though auto-entered date or timestamp records are also used for this.

                  • 7. Re: New portal record at top of portal
                    JohhnyHilly

                         Yep I have sorted that filter already, but what I was wanting to do was to be able to enter a record at the top of the portal not at the bottom. When portal records get large, the user has to scroll all the way down to the bottom of the portal each time to enter the new record. After a while you get sick of scrolling to the bottom every single time. I'm actually surprised the portal is not set up like this in the first place anyway. So is that possible?

                    • 8. Re: New portal record at top of portal
                      raybaudi

                           "So is that possible?"

                           Yes, with a single row filtered portal.
                           I do not understand why you can't apply the tecnique I suggested.

                      • 9. Re: New portal record at top of portal
                        philmodjunk

                             That's exactly what I am describing.

                             You click a button to run the script. A new blank record appears in the top of your portal. The script produces the new record, the sort order places the new record at the top.

                        • 10. Re: New portal record at top of portal
                          JohhnyHilly

                               @Phil, sorry yes you are right as usual. It wasn't working for me as I had one of the fields set to "Not Empty". Once I removed that it works as you described. Is it possible though to still have a field validation set to "Not Empty" with your method, since it goes to another layout to create the record. When it tries to go back to original it says field must contain a value.

                               Also, I have a button for "Delete Portal Row" and when I click that now it deletes all portal records. Why is that?

                               @ray, as I mentioned I was having the same issue as another person on the thread you linked where instead of creating a record, it was just changing the text of the most recent.

                          • 11. Re: New portal record at top of portal
                            philmodjunk

                                 Yes and no. You could, immediately after creating the record include this step:

                                 Commit Records [Skip data entry validation]

                                 That will keep the validation message from popping up, but also allows a blank record to be created that won't trip an error message until you actually start entering data into the new record.

                                 

                                      Also, I have a button for "Delete Portal Row" and when I click that now it deletes all portal records. Why is that?

                                 What options have you selected for that button? Delete Record or Delete portal row? It sounds like the layout's record was deleted instead of that of the portal record. That could happen if you specified delete record instead of delete portal row and if your script is "losing" the focus on the portal row where you clicked the delete button. (Commit records will drop the portal row focus so it's "suspect number 1" for when this happens.)

                                 You may find the delete portal row script in the Known Bugs List Database useful. It can be imported error free from that file into any file of the same type (.fp7 or .fmp12).

                            • 12. Re: New portal record at top of portal
                              JohhnyHilly

                                   In my script it has Delete Portal Row. However, it has lost focus on the portal row as when I click that button it deletes the active record in the other portal on the layout (the first one with the equipment list on).

                                   I tried adding Go To Object to my script before it deletes the portal row but it doesn't work, it still deletes the record in the other portal. I am really not sure why this is happening as it was working fine before I adjusted the portal to have the record appear at the top. With this is mind how do I get the focus back on the Service History portal?

                              • 13. Re: New portal record at top of portal
                                philmodjunk

                                     What is causing the loss of the focus? If this button is located inside the portal row, such a loss of focus should be fully avoidable. (Commit record is the most common culprit.)

                                     Go to object should put the focus on the correct portal if you have correctly specified object names in the Inspector as well as in the go to object script step, but this only puts the focus on the portal, not a specific row within the portal and thus will delete the first portal row instead of the row that you clicked. You'd need to follow the go to object step with a go to portal row step and specify the portal row by number. The only way you can do that is if your script to delete the portal row captures that number and stores it in a variable--all a more complicated method that should not be necessary just to delete a portal row in most cases.

                                     But there could be details about your layout design and this script that you haven't shared yet...