4 Replies Latest reply on Nov 23, 2009 9:55 AM by philmodjunk

    Scripting help

    NGC

      Title

      Scripting help

      Post

      I was wondering if anyone can help me. I am new to FMP and need help to create a script.

       

      I am trying to create a script that will perform a find based on one of the fields within a layout. The field is an invoice field and each time it will be different vaule so I cannot specify a value to search for. Sorry if this is an easy thing to do but as I said am new to FMP.

       

      Cheers and Thanks in advance

        • 1. Re: Scripting help
          littledog
            

          Try following:

          Go to Layout (Your layout)

          Go to Field (Your content changing field)

          Copy 

          Enter Find mode

          Go to field (Your field where you want to find something - probably the same field you copy from)

          Paste

          Perform Find

           

          • 2. Re: Scripting help
            raybaudi
              

            The copy/paste method is highly deprecated.

             

            Use your $var ( or a global field ) instead. Something like:

             

            Set Variable ( $find ; Value: YourTable::YourField )
            Enter Find Mode [ ]
            Set Field [ YourTable::YourSearchField ; $find ]
            Perform Find [ ]

             

            The script above is minimal... you may need to add a trap for errors due to lacking of record that satisfy the given condition.


            • 3. Re: Scripting help
              NGC
                

              Thanks Littledog, that did the trick!

               

              Cheers

              • 4. Re: Scripting help
                philmodjunk
                  

                Daniele's method is much better. Using copy and paste like this leaves you open to having your script fail to work (and without displaying any error message to tell you that it failed or why.) if one of the fields referenced by the copy and paste steps are removed from the layout at some future date. It also destroys any data that the user may have copied to the clipboard.

                 

                Using Set Field/Set Variable avoids both issues.