3 Replies Latest reply on Jun 26, 2012 9:10 AM by philmodjunk

    Check that correct portal is active



      Check that correct portal is active


      I have a layout with two portals and I have a button that can be pushed to delete a record from the portal. Is here a way to check that the correct portal is active before deleting the related record?

        • 1. Re: Check that correct portal is active

          If the button is located inside the portal row--as it should be so that the user's click also selects which record in the portal to delete, and your script does nothing such as commit records, go to object or go to field to change the focus, such a check should not be necessary in order to delete the correct portal row.

          • 2. Re: Check that correct portal is active

            Like in these portals there is a red cross button in the portal row and it's script step (in button setup) is "Delete Portal Row".

            That's the best way to delete specific records in a portal if you ask me.

            Portals with delete buttons

            • 3. Re: Check that correct portal is active

              Here's the script that I use for deleting portal rows. It highlights the row to be deleted and displays a custom dialog with a message that includes data from the clicked portal row and also the row number. The same script can be used to delete portal rows from any portal on any layout in the file. It also imports error free into any new database file, so it's a utility script I can import into any new project an just start setting up portal row buttons to perform it.

              The key is in the 2 value list passed as a script parameter when the delete button in the portal row is clicked.

              You can download the Known Bugs List database and import this script from it if you wish to use it in your own solutions. You can also find examples of conditional formats for the buttons and tool tip text that further make the delete portal row as "user friendly" as possible.

              #Created by Phil Caulkins
              #This script functions independently of all layouts/tables. It can be cleanly imported into any filemaker file.
              #Delete row of portal where button was clicked after User Confirmation.
              #This script is designed to work with all portals where you want to use a button to delete a portal row.
              #Parameters are passed in a 2 value list.
              #Parameter 1 should be a boolean value to disable this script if the button is clicked on a blank "Add" portal row.
              # Not IsEmpty (portalTO::Keyfield) is often the best expression to specify as this parameter.
              #Parameter 2 should contain text to be included in the custom dialog to aid the user in identifying which row is about to be deleted.
              # Often, this is the contents of one or more fields shown in the portal.
              #Check the custom formatting and tool tips found attached to the delete buttons in this file for additional ways to make this method user friendly.
              Set Variable [ $RowExists; Value:GetValue ( Get ( ScriptParameter ) ; 1 ) ]
              Set Variable [ $Label; Value:GetValue ( Get ( ScriptParameter ) ; 2 ) ]
              If [ $RowExists ]
                     #Highlight the portal row to be deleted.
                     Go to Portal Row [ Get ( ActivePortalRowNumber ) ] [ Select; No dialog ]
                     #Confirm that button was not clicked by mistake.
                     Show Custom Dialog [ Title: "Confirm Row #" & Get ( ActivePortalRowNumber ) & " Deletion"; Message: "Delete " & $Label & "?";
                                                      Default Button: “Cancel”, Commit: “No”; Button 2: “OK”, Commit: “No” ]
                     If [ Get ( LastMessageChoice ) = 2 /* OK was clicked */ ]
                             Delete Portal Row [ No dialog ]
                             #Commit releases the focus from the portal row so that it no longer is highlighted.
                             Commit Records/Requests
                     End If
              End If