6 Replies Latest reply on Jul 29, 2016 2:14 AM by alangodfrey

    Script does not capture next portal row on first click

    alangodfrey

      I have a portal that users can click in to select a Resident's record to display.  They often want to progress down the portal list, viewing a record, then the next, then the next, etc.  To make it easier for them I collect the ID of the record they want to view (obviously) and display it, but I also collect the ID of the next record in the portal.  They can see who the next Resident will be, and clicking a 'Next' button shows them that 'next' Resident's record, and traps the new 'next' Resident.

       

      So they can click on the first record in the portal, then use the 'Next' button to 'walk' down the list.  The problem is it the 'Next' button fails when used the first time, but works every time after that.  So: click on record 1 in the portal, and it will correctly show record 1 and note that record 2 is next in the queue.  Clicking on the 'Next' button will load record 2, but show (wrongly) that the 'Next' record is still 2.  Clicking again, will correctly move on through record 3, 4, etc.

       

      I have attached a stripped down sample of the problem - in the real file I have other error checks, and checks for the first or last record, and also the ability to walk back 'up' the portal, but this has me stumped.  Using the Script debugger shows everything going correctly visually (I can see the correct portal row is correctly selected) but the data it displays is consistent with the problem.  I just can't see why the ID from the 'active' row is correctly collected every time except the first time.

       

      All help gratefully received - thanks.

      (The file is being developed in version 11, but I have converted it to version 14 and it still displays the same problem.)

        • 1. Re: Script does not capture next portal row on first click
          philipHPG

          In your Select Next Resident script, line 21 is using the Residents::gPortalRowSelected field, but that field has not been set within the script (see line 5 of Select Resident script)

          • 2. Re: Script does not capture next portal row on first click
            philipHPG

            Sorry about that, previous response was incorrect. Residents::gPortalRowSelected is set in the Select Resident script.

             

            There is an inconsistency in where the Select Resident and Select New Resident scripts are leaving the gPortalRowSelected field. Select Resident leaves the gPortalRowSelected field as the currently selected portal row, whereas Select New Resident leaves gPortalRowSelected as the next portal row.

             

            Increment the Residents::gPortalRowSelected field at the end of the Select Resident script to match what is happening in the Select Next Resident (line 30) script or change your Select Next Resident script to move down two rows to find the Next Resident.

            • 3. Re: Script does not capture next portal row on first click
              alangodfrey

              Thanks, philipHPG - I had tried moving down two rows before, but of course it then jumped two rows every time.  I may have tried that in the wrong place, of course.  The original script is more complex, but I stripped it down to this bare minimum, and the oddity still shows.

               

              The logic for the 'Select Resident' script leaving the gPortalRowSelected field as the currently selected portal row is to have that benchmark of 'which row the user last clicked on', and then I can increment up and down from that known point.

               

              The logic for exiting the 'Select Next Resident' script as the next row down (from the last row actually clicked on) was to imitate the user actually clicking in the portal, one row down from the last click.  I hoped that would make other associated scripts more reliable - no matter how the ResidentID has been selected, the associated scripts starting point will always be the same.

               

              When I watch the script in the data viewer it shows the correct portal row as active (the cursor flashes in a field in the correct row) but the next step of capturing the relevant ResidentID actually captures the ID of the previous portal row - except on every subsequent click.

              • 4. Re: Script does not capture next portal row on first click
                philipHPG

                In that case, in the Select Next Resident script, move lines 29 and 30 up to line 8 (move the portal row down before you start reading it).

                 

                Also, you probably want to add the error checking from Select Resident into Select Next Resident, but you've probably done that in your full script.

                • 5. Re: Script does not capture next portal row on first click
                  fitch

                  As philip noted, you're setting your gPortalRowSelected field differently in your Select vs. Select Next script. That's the issue.

                   

                  But I'd suggest taking a different approach. There's no need to keep jumping in and out of the portal. Use the List function to grab all the IDs when you click Select, and then when you click Next, use GetValue from that ID list to set your Selected and Next values.

                  • 6. Re: Script does not capture next portal row on first click
                    alangodfrey

                    Thanks, Tom - unfortunately I can't use the 'List' and 'GetValue' trick as in the real file the user types in a global field to filter the portal.

                     

                    You've both made me realise I was confusing the 'Next' Row with the 'next-Next' Row.  I made it more clear (to myself) by returning to the 'Original' Row, stepping down one to the 'Original Next' Row (as before), then correctly trapping it as the new 'Row last clicked on' (as Philip suggested), then stepping down another Row to capture the 'New Next' Row.

                     

                    Thanks very much for your help,

                    Alan