2 Replies Latest reply on May 21, 2015 1:38 PM by philmodjunk

    Script Printing Issues



      Script Printing Issues



          I'm running a FMP script to help print my records. My script is messing up and keeps printing all records instead of what I need.

      A little backround for the coding:

      Table is called Task Bank
      I have two fields that are used in the script:

      ADTAB Search - A global storage field that is on a list view of my records that runs a script when saved called "ADTAB | Quick Find". The script is below and works fine.

      Record Reference - A serial auto-entry field that just assigns a numerical value to the record. (e.g. 001, 002, etc.)

      See links below for the code, links to a code sharing site www.codeshare.io

      Print script    Search Script

      I just need help understanding why this isn't sorting out correctly. Any script suggestions would be lovely.

        • 1. Re: Script Printing Issues

          The easiest way to fix this is by using the script debugger.  Some thoughts/questions.

          Does Line 5, perform quick find, result in the proper records?

          After you perform quick find, you use GTRR, does it take you to the proper related records?<<This seems to be my best guess where the problem may be occurring.  You have Show Related records, but do you have selected Match current record only, or Match all records in current found set?

          Your prints script steps should be preceded by Print Setup steps where you can select printer, print current record or print all records in current found set

          Your Print script steps also don't show any parameters.

          From a FM script stand point, You should set the field reference to a variable, then set the field.  Don't know why you need the quick find.  Cleaner would be

          Set Variable [$id:; Value: Task Bankd::ADTAB Search]

          Enter Find Mode[ ]

          Set Field [Task Bank::Record Reference; Value: $id]

          Perform Find [ ]

          One nitpicky thing,

          Line 8 If [Get (LastError) ≠ 0], could simple be If [Get (LastError) ]


          Your other script, disregarding the quick find which I referenced earlier, would be cleaner like this:

          If [Get (LastError) =400]
           Show All Records
              Go to Record/Request/Page [First]
          Else If [Get (LastError) = 401]
           Go to Record/Request/Page [First]
              Omit Multiple Records [No dialog; Get (FoundCount)]
          End If

          //If it's not one of those 2 errors, you want to end the script, no reason to check for No Error
          //don't know why you are using Halt Script Steps


          • 2. Re: Script Printing Issues

            Minor point that can lead to a slightly simpler script:

            since ATAB Search is a global field, you do not need to set it to a variable. You can enter find mode and the set field step can copy the value from the global field to the nonglobal field into which you want to insert find criteria.