5 Replies Latest reply on Jan 5, 2013 3:26 PM by philmodjunk

    Help to set up script for delete button in Portal...

    hanstrager

      Title

      Help to set up script for delete button in Portal...

      Post

           I have a portal, where I have button that adds records into the portal. I've tried to make a button that will delete a record in the portal. I've been lucky enough to get some help allready with some script that should be attached to a button and it should delete a record, but it dosen't seem to work for me, im quite new to filemaker, and scripting is absolutely not my strong side... Help please... the script is as follows, and I have activated "allow deletion of portal records" in the portal setup:

           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
           & "?"; Buttons: “Cancel”, “OK” ]
           If [ Get ( LastMessageChoice ) = 2 /* OK was clicked */ ]
           Delete Portal Row
           [ No dialog ]
           Else
           #Commit releases the focus from the portal row so that it no longer is highlighted.
           Commit Records/Requests
           End If
           End If
           #Created by Phil Caulkins
            

      Picture_2.png

        • 1. Re: Help to set up script for delete button in Portal...
          philmodjunk

               In portal setup, is delete row enabled?

               What paramter are you passing to this script?

               Is the delete button located inside the portal row?

          • 2. Re: Help to set up script for delete button in Portal...
            hanstrager

                 in portal set up i've enabled the check box called "allow deletion of portal records"

                 not sure what you mean by "parameter"..?

                 The delete button is located inside the portal row.

            • 3. Re: Help to set up script for delete button in Portal...
              philmodjunk

                   Note the first two lines of the script:

                   Set Variable [ $RowExists; Value:GetValue ( Get ( ScriptParameter ) ; 1 ) ]
                   Set Variable [ $Label; Value:GetValue ( Get ( ScriptParameter ) ; 2 ) ]

                   A script parameter must be passed to this script with two values in the list. The first value must be a boolean value (True (1) or False (0) ). The second value is text used in the confirmation custom dialog that asks the user if they really want to delete that portal row. Of that first value is false, the script does nothing. If you do not pass a parameter to the script, the script does nothing.

                   In the Known Bugs List file where you got this script, go to a layout with a portal, enter layout mode and double click the delete button in the portal row to bring up button setup. Then click the specify button to bring up the dialog where you'll find the optional script parameter box. Then click edit to see the full expression used to create a list of values to be passed to the script. This parameter expression is what is key to having a script that works with any portal in your file and which can be imported error free into any other database file.

              • 4. Re: Help to set up script for delete button in Portal...
                hanstrager

                     it works perfect, just needed to add List ( True; Line Items::fabric_Category ) to the optional script, thank you soo much...

                • 5. Re: Help to set up script for delete button in Portal...
                  philmodjunk

                       If you can add new records in the portal to Line Items, there's a better option than using True as the first list value. Then you can use conditional formatting to make the delete button invisibile or look "disabled" on the bottom "add row" of the portal.