2 Replies Latest reply on Apr 1, 2011 6:45 AM by james.gould

    Scripted scrolling in list view

    james.gould

      Title

      Scripted scrolling in list view

      Post

      We have a list view of various projects each falling into a specific month. When opening the list view I have a script that sorts the records by month.

      What I want to do is scroll to the current month - but I want all months to view by scrolling up or down, so I can't perform a simple find for the month I want. (and in some cases the found set is important).

      Obviously I can use the Get ( CurrentDate ) function for identifying the current month but scrolling to the record for this month seems to be a bit of an issue. Using the "Go to Record" script step requires a record number - but I'm not sure how to calculate/get a record number for a project from this month.

      Any help would be greatly appreciated.

        • 1. Re: Scripted scrolling in list view
          philmodjunk

          With go to record, you'd have to go to the first record, then loop through the records with go to record [next] until you reach the desired record.

          Here's a sneakier way to do it without all the looping records:

          If you haven't already done so, define a auto-entered serial number field to uniquely identify each record. Define a new global field, gSelectedRecord that is also of type number.

          Define a self join relationship like this:

          YourTable::gSelectedRecord = YourTable2::SerialNumberField

          Now let's perform two finds. First a "tight" find that only finds records of the current month that also meet your search criteria, then a "loose" find that finds all the records you want to display.

          In your script perform the "tight" find. Then your script does this:

          Sort Records [restore ; no dialog]
          Go To Record/Request/Page [First]
          Set Field [YourTable::gSelectedRecord ; YourTable::SerialNumberField]

          Now perform the find that finds all the records you want to see on the layout. Then do this step:

          Go To Related Record [ From table: YourTable2; Current Layout ]//do not select "show only related records"

          This makes the first record found in your first find the current record.

          • 2. Re: Scripted scrolling in list view
            james.gould

            Works like a charm - Thanks.

            I've also adapted it elsewhere, using a calculation (rather than a global) as the match field to save time searching!