1 2 3 Previous Next 43 Replies Latest reply on Nov 4, 2011 11:58 AM by philmodjunk

    Delete Portal Row

    dg3321

      Title

      Delete Portal Row

      Post

      What is the easiest way to delete a portal row?  I'd like to create a button with a script to delete a row within the portal however it is not working.  How should the script read?

        • 1. Re: Delete Portal Row
          mgores

          There is a delete portal row script step you have the option of peforming with or without a dialog.  If you place a button in the portal row it will delete that row.

          Phil recently posted another script that lets you highlight a portal row to ensure the focus is on the right row to delete.  I'm sure you can find it if you do a search on it.

          • 2. Re: Delete Portal Row
            philmodjunk

            Here's a file you can download that contains a delete portal row script. You can import this script into any fileMaker file and it will import cleanly as it has no file, layout, table or field references in it. The needed info is passed as a script parameter to the script. You can check button setup on any delete portal row button in this file and see how this script parameter is configured and there are extensive comments inside the script that also explain the structure and purpose of this multi-value parameter:  http://www.4shared.com/file/8orL8apk/FMP_Bugs.html

            Minor correction to Mark: The script does not set the focus. The button click on the button inside the portal row does that. The script steps in this script that highlight the portal row, do so as a way to visually indicate which row will be deleted if you confirm that you want to delete that portal record.

            • 3. Re: Delete Portal Row
              mgores

              Smile  That is what I meant.

              • 4. Re: Delete Portal Row
                dg3321

                Thanks so much Phil.  Where in that download will i find the delete portal row script?

                • 5. Re: Delete Portal Row
                  philmodjunk

                  On the Bug Reports layout you'll find several portals. The red x is the delete portal row button. You may want to examine their tool tip, conditional formats and script parameter settings for ideas. These buttons run the same script titled "Delete portal Row".

                  • 6. Re: Delete Portal Row
                    dg3321

                    i copy and pasted the delete portal row script and assigned it to the delete button in my portal but it is still not deleting the row.  It doesn't even delete if i highlight the row and click delete on the keyboard.  any suggestions?

                    • 7. Re: Delete Portal Row
                      philmodjunk

                      To repeat, "you may want to examine their tool tip, conditional formats and script parameter settings."

                      The correct info must be passed in a list of values as a script parameter to this script. If you read the comment block at the top of this script, it will list each value in the list, its purpose and the order in the list that it has. Your portal row button has to pass this list to the script in order for it to work.

                      The first value is a boolean. If true, the script goes ahead. If false, it stops. This keeps the button disabled if you click the button in the blank "add" row of a portal that allows the user to add new records in the portal. You use an expression such as PortalTable::PrimaryKey as this first value. If the user clicked the button in the add row, this field will be empty and this evaluates as false.

                      The second value is text used in the custom dialog that pops up to confirm the portal row deletion. This is here so that you can pass info specific to that portal row. IF there's a name field in the portal row and you pass that field as the second value, the custom dialog asks "Do you want to delete George?" if "George" is the text in the name field of the row where the delete button was clicked.

                      To put all of this together, If you have a portal to a table occurrence named "Details", with a field in the portal named "Name", You might use this expression as the script parameter:

                      List ( Not IsEmpty ( Details::ForeignKeyField ) ; Details::Name )

                      • 8. Re: Delete Portal Row
                        dg3321

                        Ok.  So i created a boolean value for the first parameter which seems to work.  I edited the custom dialog and the only problem with that so far is that i included two of the fields from the portal in the custom dialog and all of those values are bunched together w/ no spaces.  How do i create a space between each field in custom dialog?

                        When i click on a portal row with nothing in it, nothing happens, so that's good.  When i click on a portal row with information in it, a dialog box appears asking if i want to delete that row (w/ additional info as mentioned above).  When i click ok, the row still does not delete.  

                        I've included the following parameter when linking the button to the script:

                        List ( not IsEmpty (Savings Account Portal::S_ID) ; Savings Account Portal::Category)

                        I'm not following what should be in the bold portion of the parameter above as i have 7 different fields in the portal.

                        Also, here is the script itself:

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

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

                        If [$RowExists]

                        Go to Portal Row [Select; No dialog; Get ( ActivePortalRowNumber)]

                        Show Custom Dialog ["Confirm Deletion"; "Delete" & (Savings Account Portal::Date) & (Savings Account Portal::Category) & "Entry" & "?"

                        If [Get ( LastMessageChoice ) = 2 /*OK was clicked */]

                        Delete Portal Row [No dialog]

                        Else

                        Commit Records/Requests []

                        End if 

                        End if

                         

                        Thank you.

                        • 9. Re: Delete Portal Row
                          philmodjunk

                          When i click ok, the row still does not delete. 

                          Check portal setup... Delete portal row must be enabled before the script will work.

                          I'm not following what should be in the bold portion of the parameter above as i have 7 different fields in the portal.

                          I would think using all 7 fields is a bit excessive, but it's your call and I can't see your layout--which might change my opinion here.

                          You can use an expression like this:

                          List ( not IsEmpty (Savings Account Portal::S_ID) ; Savings Account Portal::Category & " " & Savings Account Portal::Field2)

                          To combine the data from two fields with a space between them. You can also use ", ", or "|" or even ¶ (if you want to start remaining text on a new line. That should show you how to extend the idea to include all 7 fields if you want.

                          Basically, you can put the same expression inside this parameter of the list function composed exactly like you would in the specify calcualtion dialog of Show Custom Dialog if you were to include this text directly in that step.

                          • 10. Re: Delete Portal Row
                            dg3321

                            'Allow Deletion of Portal Records' is checked.

                            Are you saying that using 7 fields in the portal is excessive or using 7 fields in the parameter is excessive?

                            I thought you meant in the expression so i created the following:

                            List ( not IsEmpty (Savings Account Portal::S_ID) ; Savings Account Portal::Date & Savings Account Portal::Category & Savings Account Portal::Withdrawal & Savings Account Portal::Deposit & Savings Account Portal::sBal & Savings Account Portal::Notes)

                            This still did not delete the portal row.

                            Thanks for the tip on how to get the space in the dialog box.

                            • 11. Re: Delete Portal Row
                              philmodjunk

                              From the user perspective, it seems like a lot of data to pop up for them to read--especially when the portal row highlights and the row number is included in the title of the confirmation dialog anyway.

                              Where is the button for deleting the portal row located? it should be located completely inside the portal row of the portal where this will delete the record. Do you see the correct portal row change color when you click this button? (The mouse click on the button activates a the portal row to delete so this has to take place in order for the script to work.

                              • 12. Re: Delete Portal Row
                                dg3321

                                No, i don't need the user to see all of that information.  I'm sorry i got confused and thought that that 2nd part of the parameter had to do w/ the function of actually deleting the row.  No, i just need them to see the date and category in the dialog box.

                                I'm more concerned with the fact that the deletion is not happening.  I drew a small rectangle at the end of the portal which is the button.  The entire portal row does highlight when i click the button.  Then the dialog box appears, then i click ok, but then it does not delete.

                                • 13. Re: Delete Portal Row
                                  philmodjunk

                                  What operating system are you using?

                                  Sure sounds like "delete portal row" is not enabled for the portal, but you confirm that you've selected that option...

                                  • 14. Re: Delete Portal Row
                                    dg3321

                                    Lion OS 10.7.2

                                    Yes, it's selected.  Do i have to select any deletion options in the relationship between to the two tables?

                                    1 2 3 Previous Next