13 Replies Latest reply on May 28, 2009 2:01 PM by Terri

    Can Set Field step work with fields in the header?

    Terri

      Title

      Can Set Field step work with fields in the header?

      Post

      I am using FMP 9 - I am trying to write a script that will perform a find by grabbing data data from one field and putting it in another. Currently my script looks basically like this:

       

      Enter Find Mode

      Set Field [Catalogs::Field A; Field B]

      Perform Find

       

      Field A and B are in the header of my layout. When I execute the script there are no found records (which there should be) and my cursor is in the body of the layout in a totally different field.

       

      Do Field A and B have to be in the body? What am I doing wrong?

       

      Thanks!

       

       

        • 1. Re: Can Set Field step work with fields in the header?
          philmodjunk
            

          Set Field is not affected by a field's location on a layout.

           

          In order for your script to work, Field B would have to be a global field.

           

          If you can't have Field B as a global, do the following:

           

          Set Variable [$FieldBVal, Field B]

          Enter find mode[]

          Set Field [Catalogs::Field A; $FieldBVal]

          Perform Find

           

          When you enter find mode, it's as though you now have a blank record in which to enter your find criteria and any data in the current record is no longer available to your script. Thus, you have to use global fields or variables.

          • 2. Re: Can Set Field step work with fields in the header?
            Terri
              

            I think I am finally starting to understand Global Fields. So I switched that field.

             

            But now it has the error: there are no valid criteria in this request. Type a valid request before clicking find.

             

            I can't seem to figure out what "criteria" I am not specifying.

             

            Thanks!

            • 3. Re: Can Set Field step work with fields in the header?
              philmodjunk
                

              That error message suggests that your set field is not entering the data you think it is.

               

              Try this script on a layout where all the required fields are visible. Perform the script, dismiss the error and then choose Records | Modify Last Find. This should bring up the find request your script attempted on your layout so you can see what didn't work.

              • 4. Re: Can Set Field step work with fields in the header?
                Terri
                  

                This is where there is nothing - only a blank record with my cursor in the wrong field (blinking rather irritatingly at me).

                 

                So I get the feeling it isn't entering any data.

                 

                • 5. Re: Can Set Field step work with fields in the header?
                  raybaudi
                    

                  Hi

                   

                  while in Browse Mode, what can you see inside the ( just transformed to global ) fieldB ?

                  • 6. Re: Can Set Field step work with fields in the header?
                    Terri
                      

                    Field B has this data: 3G09

                     

                    • 7. Re: Can Set Field step work with fields in the header?
                      raybaudi
                        

                      There are records with Catalogs::Field A ( text field ) containing: 3G09 ?

                       

                      Catalogs::Field B is a global TEXT field ?

                       

                      Are you using your original script:

                       

                      Enter Find Mode

                      Set Field [Catalogs::Field A; Catalogs::Field B]

                      Perform Find [ ] <----inside brackets there MUST be nothing expecially "Restore"

                       

                      ?

                      • 8. Re: Can Set Field step work with fields in the header?
                        Terri
                          

                        raybaudi wrote:

                        There are records with Catalogs::Field A ( text field ) containing: 3G09 ?

                         


                         

                        Yes, each record has a text field in it that contains this information. It isn't 3G09 exactly - it is 33_3G09_1A.

                         

                        Right now I can go into find mode - type this into Field A - and it will find all the records with this data. I want FileMaker to do this by itself without me typing into Field A. I want it to pick up the info from Field B.

                         

                        Right now, through more research online and reading my "bible" my script looks like this:

                         

                        Set Variable [$Field; Value:Catalog Pagination::Field B]

                        Enter Find Mode[]

                        Set Field [Catalog Pagination::Field A; $Field]

                        Perform Find[]

                         

                        Any idea why I am still getting an error that says There are no valid criteria in this request?

                         

                        Thanks!

                         

                         


                        • 9. Re: Can Set Field step work with fields in the header?
                          philmodjunk
                            

                          Change Set Field [Catalog Pagination::Field A; $Field] to

                           

                          Set Field [Catalog Pagination::Field A; "*" & $Field & "*" ]

                           

                          If your underscores where spaces, this would not be necessary.

                          • 10. Re: Can Set Field step work with fields in the header?
                            Terri
                              

                            We are closer. I didn't get the error message but I also didn't get any records that have 3G09 in them.

                             

                            I am surprised I need to address the underscore thing when manually I don't. I just put in 3G09 and they all pop up. I can put just that in Field A and it works and I can also put just that in the ID field and it works. It is probably a script thing but it still makes me wonder why.

                             

                            I only have FMP 9 but another coworker has FMP Advanced with Script Debugger. I am going to try that and see if it can tell me what it is trying to do.

                             

                            Thanks for your ongoing help.

                             

                             

                            • 11. Re: Can Set Field step work with fields in the header?
                              philmodjunk
                                

                              I figured that the underscore was the issue, but if it works when you enter the criteria by hand then probably not.

                               

                              The script debugger sounds like a good idea--especially if you use the Data Viewer at the same time. (Click the "x=" button on the script debugger.)

                              • 12. Re: Can Set Field step work with fields in the header?
                                Terri
                                  

                                I just left the script as you had it and took off the perform find step because I wanted to see where it landed before actually performing the find. Happily it is in the right field and it put * * in it. So that means it is doing everything right but it is NOT picking up the 3G09 field like I want it to. So I'll be working on that.

                                 

                                Thanks!

                                • 13. Re: Can Set Field step work with fields in the header?
                                  Terri
                                    

                                  Problem solved. In the end the problem was with the field I was using as the variable. Long story short I was using a field that was called something very similar in another, but wrong, table.

                                   

                                  If anyone takes the time to read this long post the answer to the original question "Will Set Field step work if the fields are in the header" the answer is - yes, it doesn't matter.

                                   

                                  To answer the question "How do you write a script that has FileMaker go to another field on the same layout, pick that data up and do a find with it" the answer is:

                                   

                                  Set Variable [$Field; FieldB]

                                  Enter Find Mode []

                                  Set field [Field A; $Field]

                                  Perform Find

                                   

                                  The set variable was the important part because if you don't do that before you go into find mode, FM doesn't know what to use in the Set Field step.

                                   

                                  And that is my final answer.

                                   

                                  Thanks to all who helped.