9 Replies Latest reply on Mar 18, 2015 11:57 AM by philmodjunk

    Removing from a portal

    AndrewJudd

      Title

      Removing from a portal

      Post

      I have a script that is supposed to remove artworks from a portal. I use portals for making invoices and consignment forms and my script is similar for both.

      When the script runs it just removes the most recently added artwork to the portal rather than the one on the selected line. For example, clicking the remove button on the bottom artwork here (Matthew Deleget), will remove the top artwork (Cordy Ryman).

      I'll include my script below and my relationship graph, any ideas would be fantastic.

      thanks!

       

      Screen_Shot_2015-03-18_at_09.27.51.png

        • 1. Re: Removing from a portal
          AndrewJudd
          /files/2a6abcee52/Screen_Shot_2015-03-18_at_09.29.36.png 704x329
          • 2. Re: Removing from a portal
            AndrewJudd
            /files/3de8749be4/Screen_Shot_2015-03-18_at_09.29.52.png 1113x502
            • 3. Re: Removing from a portal
              philmodjunk

              Your script loses the focus on the portal row when it changes layouts. Thus references to the portal table refer to the first record by default. 

              Your script also leaves disconnected records in the portal table instead of deleting them. 

              • 4. Re: Removing from a portal
                AndrewJudd

                Thanks, removing the change in layout has fixed it, however, if I want to incorporate marking an artwork as available (in it's status field) how do I do this when removing from the portal at the same time?

                • 5. Re: Removing from a portal
                  philmodjunk

                  Two options:

                  Option 1: Set up and use a relationship to an occurrence of that table which allows you to modify the value of this field without changing layouts. If I read you relationships correctly, you can set a field in "Artwork for consignments" to do that.

                  Option 2: Set a variable to the artwork ID. After deleting the portal record, switch to a layout for that table, use the value in the variable to perform a find for the record, update it and then return to your original layout.

                  • 6. Re: Removing from a portal
                    AndrewJudd

                    Thanks! on a more obvious level, I have a portal here to artwork so I can just add the status field to that portal so the user can see for themselves what it is and change it accordingly.. Maybe thats what you meant!?

                    What did you mean earlier by "Your script also leaves disconnected records in the portal table instead of deleting them. "?

                    • 7. Re: Removing from a portal
                      philmodjunk

                      It's not what I meant, a field does not have to be visible on the layout in order for it to be modified by a set field script step. But you do need a way to correctly reference the correct record of your table and if you have a relationship in place that does that, your set field step can simply refer to the name of the appropriate table occurrence.

                      What did you mean earlier by "Your script

                      You have been clearing the match field of your portal record. This makes it disappear from your portal as it is no longer linked to the current consignment form record, but it's still there in the portal's table. This can create possible problems for you for a number of different database tasks so I would not do it that way. I'd delete the record.

                      • 8. Re: Removing from a portal
                        AndrewJudd

                        thanks, could you explain how option 1 works in a bit more depth?

                        I need a field in artwork for consignments that links to the table (and portal) - consignment line items - and allows editing of status? How does that work? thanks!

                        • 9. Re: Removing from a portal
                          philmodjunk

                          Not sure what more to say about option 1. I've recommended using:

                          Set Field [ Artwork_for_Consignments::Status ; "Available" ]

                          while the focus is still in your portal row (which is based on Consignment Line Items).

                          The text in blue is the name of a table occurrence in your system. When a script step or calculation refers to a table occurrence, it tells FileMaker both what table to access, but also what relationship to use in order to determine what record in that table to access.