3 Replies Latest reply on Jan 26, 2010 3:29 PM by david583

    Delete from a Portal Row



      Delete from a Portal Row


      FM Pro10, Windows XP, Hosted Network.


      I have a layout based on a table of repair codes. On the layout there is a portal of the same table with a cartesian relationship (x) which shows a list of all the codes. Selecting a portal entry populates detail fields for the record that are not shown in the portal (Go To Related Record).


      I have a delete button on the layout. When pressed it asks if I want to delete the Master or this one related record. If I select Master I get the normal delete record dialog, select yes and it works fine.


      Is there a way to do this by script in one step as the master/related dialog confuses some users?


      If I select 'Delete Related Record' or change the button to 'Delete Portal Row' the whole portal is empty as all records are deleted from the portal. I believe this is because of my relationship being cartesian. (Is there a better way to show all records in a portal based on the same table?)

      I would like to try and avoid a button on every row of the portal if possible.

        • 1. Re: Delete from a Portal Row

          Off the top of my head I'd say it's likely safer to include the Delete button as part of your portal layout . . . it will be on each row. As well, if the button's not in the row you have a whole lot more work to do in specifying the portal row as once the focus is on the button it's no longer on the row. If the "delete master/related" dialog can be trapped with error capturing (not sure . .  easy to find out) then you could present a custom dialog that involves more understandable language. Or you could disable deletion of portal rows and instead direct the user to a layout "native" to the portal table and have them make the decision there, where the context is more obvious. There are other ways of re-directing such as disallowing any kind of deletion from a given layout with a portal and redirecting.



          • 2. Re: Delete from a Portal Row

            Here's how I do it. This script highlights the portal row and displays a custom dialog that displays data from the selected portal row to confirm the delete and the buttons "Yes" and "No". Then, if the user clicks "Yes"in the custom dialog, it deletes the portal row.


            If[not IsEmpty ( PortalTO::ForeignKey ) /* There is a line to delete */]

              #Highlight the portal row

              Go To Portal Row [select; No dialog ; Get (PortalRowNumber) ]

              Show Custom Dialog ["Confirm Delete" ; "Delete " & //put expression here with one or more fields from your portal row here & "?"]

              If [get(LastMessageChoice) = 2 /* user clicked "Yes" button */]

                 Delete Portal Row [no dialog]


                 commit Record

              End If

            End If

            • 3. Re: Delete from a Portal Row

              Thanks Phil.

              It still deleted all portal records but that was because of my relationship being cartesian, changed that and it worked bueatifully.