6 Replies Latest reply on Apr 13, 2014 6:54 PM by danielfarnan

    Activating the right portal row after coming back to it

    mariusjostfm

      using: FM12 advanced (PC)

       

      Portals can be a bit**h to navigate )-: This makes me nuts since days...

       

      I have a portal, "line items", and have no other choice than leaving it to create other data in certain cases, to take away the task from users to add additional documents etc. All this works great!

       

      Using Get(ActivePortalRowNumber) fails miserably because the user will enter a date for the line item - and this can sort the portal row anywhere in the portal. This leads to losing row focus and it means after entering "2x Northsea Fish, 12 March 2014", the row is immediately sorted into the middle of the portal just after entering the date via the date selector.

       

       

       

      However:

      When I come back to the portal, and of course I am equipped with the original RecordID, using Get(RecordID), I use the following self-join: (both tables represent the lineitems table)

       

      lineItems_GobalRecID lineitemsForPortal

      global.RecordID----------------------------------function.RecordID

       

      I have read in the Filemaker online scripting reference that I can use go to related record:

      "

      If this script step is used from an active portal row, and the portal’s table is the related table, then the related record in that table is made current. If the portal’s table is not the related table, the first related record in the found set is made current.

      "

       

      At the moment my script looks like this:

       

      While in the portal: setFieldValue global.RecordID =Get(RecordID)

       

      then I leave portal to create some important data in different other tables (really no other choise)...

       

      Go to layout LineItems

      go to object [lineitemsPortal]

      Go to portal Row [Select:Last] //works, but It just hightlights the last record ID, but will not go to the record I had originally worked at.

      Go to Related Record [From table: "lineItems_GlobalRecID; using layout: unknown] //I had also tried "from Table "lineItems_GobalRecID" here.. did also not work.

       

      How can I make this work? Do I have to "activate" a field or row before executing "go to related record"??

       

      Thanks for any hints!!!

       

      Marius

        • 1. Re: Activating the right portal row after coming back to it
          erolst

          Your description is somewhat confused – you lost me with the self-join. Please tell in a few simple sentences what you're trying to achieve, not what you have tried and failed.

           

          i.e. …you

          • are on layout x in portal y

          • need to go to layout z to create related (?) records

          • return to layout x and want to go to the same record in that portal, even though it may have changed its position (?)

          mariusjostfm wrote:

          Portals can be a bit**h to navigate )-:

          I think I can guess what one of the asterisks stands for –… but the other one …?!

          • 2. Re: Activating the right portal row after coming back to it
            rgordon

            You need to capture the portal row number right before you leave the portal

            SetVariable($row;Get(ActivePortalRowNumber))

             

            Your script has you returning to the last portal row. You need to return to the portal row with a calculation that find the $row portal row

            Go to Portal Row [no dialog;$row]

            • 3. Re: Activating the right portal row after coming back to it
              erolst

              rgordon wrote:

               

              You need to capture the portal row number right before you leave the portal

              SetVariable($row;Get(ActivePortalRowNumber))

               

              Your script has you returning to the last portal row. You need to return to the portal row with a calculation that find the $row portal row

              Go to Portal Row [no dialog;$row]

              That's hardly helpful if, as the OP stated, the row position can change and he wants to return to the same record (IIUC …)

               

              Rather capture the primaryID and use a loop within the portal until you find it, or calculate the record's position within a List() of IDs (if the portal isn't filtered and/or sorted differently from the relationship) as the Go to Portal Row parameter.

              • 4. Re: Activating the right portal row after coming back to it
                danielfarnan

                A quick question: does the portal row need to be active or does the information enclosed within it need to be visually emphasized for the user?

                 

                If it only needs visual emphasis (and the portal never has to scroll) you can try setting a global variable to the recordID and then placing conditional formatting on the portal field(s) that evaluates when function.RecordID = $$emphasizeRecordID

                 

                 

                One thing that strikes me from your post is that the script captures the RecordID, "then I leave portal to create some important data in different other tables (really no other choise)..." and then you try to Go to Related Record - it seems to me that this is the reason for you trying to get back to the original portal row.

                 

                There are two things you can do in this situation. The first is to store a copy of the related record's PRIMARY KEY at the beginning of your script (not the RecordID) and then when you have finished your data setup, navigate to the appropriate layout and perform a find on the primary key field.

                 

                The second is to have your script immediately Go to Related Record, then navigate to the other layouts where you set the "important data" and then navigate to the layout where you need to work with the portal's records.

                 

                 

                A quick primer on how found sets work: a layout is based on a particular Table Occurrence (TO). When you find records using a particular layout, FileMaker is actually storing the found set information with the TO the layout is based on. That found set does not change until an action is taken (by the user, or a script) to omit records, to extend the set, or to replace the current found set (via GTRR or a new find). You can go into layout mode and back into browse mode - the found set will not have changed. The same applies when entering preview mode and returning to browse mode. Heck, you can enter find mode and as long as you cancel the find the found set will not change.

                 

                One interesting thing about the found set information being stored with the TO is that you can have more than one layout based on a TO - and if you change to one of those layouts, your found set stays the same. If you change to a layout based on a different TO, you will have a different found set (because you're looking at a different table) - but change back to your original layout and it will have kept the found set it had when you left.

                 

                 

                Hope this helps,

                 

                Daniel

                • 5. Re: Activating the right portal row after coming back to it
                  erolst

                  danielfarnan wrote:

                  If you change to a layout based on a different TO, you will have a different found set (because you're looking at a different table)

                  No – because you're looking at a different TO, which may still be based on the same table.

                  • 6. Re: Activating the right portal row after coming back to it
                    danielfarnan

                    Sorry, yes - my apologies for the imprecise terminology.