5 Replies Latest reply on Mar 10, 2014 10:30 AM by philmodjunk

    Setting a Script Assistance



      Setting a Script Assistance


           Set Field [ Orders::_fkTitleID]

           If []

           Perform Find/Replace [Orders::Movie= "ODB"; Find Next]

           Insert Text [ Select; Orders::_fkTitleID; "1"]

           End if 


           This script is not performing though when I click -- do you see something wrong with my script writing? Is there another suggestion that you may have for populating the fk field without doing find and insert text into another field based on the corresponding information? 

        • 1. Re: Setting a Script Assistance

          Set Field [ Orders::_fkTitleID] ----> Missing a parameter

          If [] -----> Missing a Boolean expression that can evaluate to true. Without that. tje next two steps (in blue) will never be executed

          Perform Find/Replace [Orders::Movie= "ODB"; Find Next] ------> performing a find may be a better option that Perform Find/Replace See link below.

          Insert Text [ Select; Orders::_fkTitleID; "1"]   ----> not wrong, but Set Field (correctly set up) is usually a better choice than Insert Text.

               End if

               For examples of scripted finds, see this link: Scripted Find Examples

          • 2. Re: Setting a Script Assistance

                 It now works but changes all of the information in my entry in addition to that one field -- how do I prevent that from happening? 


                 Also how do I make the script repeat for every entry? 

            • 3. Re: Setting a Script Assistance

                   You'll need to provide a much more detailed description of what you want this script to do.

              • 4. Re: Setting a Script Assistance

                     It is changing my 20+ fields when I simply want  the fk field to match up with the pk field in another table. Attached is what the script looks like, and I tried to change it to perform for every record but am unsure if I correctly did it. I am also hesitant to run the script in the fear that it will change all of the other fields on all of my records. 

                • 5. Re: Setting a Script Assistance

                       There are still multiple problems with your script. I recommend that in addition to what I am about to post, you invest some time in learning more about FileMaker from some of the available training resources such as this free tutorial from FileMaker: https://itunes.apple.com/us/book/filemaker-training-series/id787527886?mt=11


                            It is changing my 20+ fields

                       The script shown cannot change more than one field of one record. If you are seeing that, something else is part of the problem that you see.

                       Comments on your script:

                  Go to field, the first line does nothing significant. If you remove this step your script will produce the same results. The only thing that this step does is put the cursor in the fk field and this is not needed in order for the Set Field step to work.

                  Perform Find [Restore]: What criteria did you specify in here? Have you check to see if this step is finding the records that you expect this step to find? I recommend that you read the info in the link I provided in my first post on scripted finds as the techniques used there make it much easier to see what criteria is used in the find without the need to open an additional dialog box in order to see what was used.

                  Set Field: This step makes no sense as it is written in your script. Why does it refer to Orders::Movie? The extra set of Brackets here are is used if Orders::_fkTitleID were a repeating field (and an fk field should not normally be a repeating field) and you wanted this step to modify a specific repetition of this field.

                       When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.