1 Reply Latest reply on May 17, 2013 9:04 PM by philmodjunk

    Beginner Scripting Help

    flovelett

      Title

      Beginner Scripting Help

      Post

           I’ve never written a script before and need a bit of help. I'm slowly working my way through FilerMaker Pro 12: The Missing Manual, but haven't gotten to scripting yet.

      Problem: users are tired of manually entering a value for a field (payee2).

      Solution: the value of (payee2) could be automatically assigned depending on the value of the field (type).

      Steps:

             
      1.           If (type)=”BGE” set (payee2) to “BGE”
      2.      
      3.           Otherwise set (payee2) to value of field (land_other)

           Here is my script:

      If [ Intake::type = "BGE" ]

                             Set Field [ Intake::payee2; "BGE" ]

      Else

                        Set Field [ Intake::payee2; Intake::land_other ]

      End If

            

      Comments:

           Used a script trigger OnLayoutEnter to invoke the script whenever a certain layout was chosen, but uncertain if this was the best solution. Also uncertain if the Set Field command was the best way to assign the value to the field.

      Result:

           The script only entered values in (payee2) in two records instead of ALL the records in the found set. Clearly I've missed something.

           Any help truly, truly appreciated.

            

           Felicia Lovelett

            

            

            

        • 1. Re: Beginner Scripting Help
          philmodjunk

               OnLayoutEnter is only tripped when you enter the layout. Then your script only modifies the field on the current record, none of the others. If you change records nothing happens as you have not tripped the OnLayoutEnter. If you change to a different layout and return, you trip the layout again and again only the current record is modified.

               Set FIeld is an excellent way to change one field of one record. If you want to change the value of a given field in every record of your found set, use Replace Field Contents.

               Hint: Replace Field Contents can modify hundreds of thousands of records in one batch operation and cannot be undone. It's a good idea to save a back up copy of your file before trying to use replace field contents so that you can discard your current copy of the file and switch to the back up copy of it does not work the way you expected.