11 Replies Latest reply on Mar 5, 2011 12:48 AM by StefaanVerschelde

    Finding a record with a script

    StefaanVerschelde

      Title

      Finding a record with a script

      Post

      Hi all,

      I am a new Filemaker pro user with the latest version of filemaker. I came over from Access.

      As you can in Access create a subform in a form where you can find information about the subform. When you double click on the subform, the subform details open in a new form called the subform.

      I am trying this in Filemaker but I really can't find out how I have to write the script. Can someone help me?????

      The layout is called "Customer" and the related portal is called "Projects" with "ProjectID" as a related record between them.

      Now I would like to open de details of the portalinformation in a layout called "Projects"

      So the relationship is one to many between Customer and Projects.

      Now, I don't want to see all the projects of that customer but only the I click in the portal of layout Customers.

      I hope this is clear enough the get an answer.

      Many thanks for the replies!

      Scan_110530002.jpg

        • 1. Re: Finding a record with a script
          Sorbsbuster

          Welcome to Filemaker!

          The portal line has a project in it, which has an identifying ProjectID (natch).  Have a script that is attached to a button on the portal row.  (You can set the button as object in the row, or make the row itself the button)

          Have the script capture the ProjectID as a variable, $ProjectID.  Pick it up from the ProjectID Field through the portal relationship.

          Go to the Project Table's layout, presumably in Form View.

          Enter Find mode, and set the ProjectID field to be $ProjectID.

          Perform Find.

          Voila.

          (If you find that it always brings you to the first project in the portal, let me know.)

          • 2. Re: Finding a record with a script
            StefaanVerschelde

            Thanx Sorbsbuster, as I am new to this, I would like you to write the script for me so I can learn from it.

            Can you write the script that wille be attached to a button?

            Many thanx!!!

            • 3. Re: Finding a record with a script
              Sorbsbuster

              Let's say the relationship to the portal is called customer_Projects (a good nomenclature system to use).

              Then:

              # (Comment line) Capture the ProjectID from a line clicked in the Customer's project list portal

              Set Variable [$ProjectID ; customer_Projects::ProjectID )

              # Go to the Projects Table and find that ProjectID

              Go To Layout [Project Form View ]

              Enter Find Mode (uncheck the pause)

              Set Field [ProjectID ; $ProjectID ]  <-- make sure you pick up the field from the Projects Table at the top of the dialogue box

              Perform Find

              • 4. Re: Finding a record with a script
                philmodjunk

                Go To Related Records can do this in one step. Just use it carefully if your script is then intended to modify the related record in some way. In that latter case, you have to test to see if there are any related records before trying the GTRR or you check for an error code immediately after so that you script will gracefully handle such a situation and without modifying the wrong records.

                • 5. Re: Finding a record with a script
                  Sorbsbuster

                  @Phil - I suggested this method because he said "I don't want to see all the projects of that customer but only the I  click in the portal" and I thought it was simply-understood technique that could also have other uses.  I also didn't check for 'No found set' on the basis that if there was a portal row to click on there must be at least one matching Project record.

                  • 6. Re: Finding a record with a script
                    philmodjunk

                    @Sorbsbuster--nothing wrong with your script. I use and recommend that aproach all the time. I'm just providing a second alternative.

                    When I talked about checking for related records, I'm referring to an issue with GTRR, not with your script--an issue that is unlikely to be a problem in this case, but I always add that warning for folks who might try to take this idea a bit further. If the portal is set up to allow creating new related records, you can click this button on the bottom blank "add" row of the portal. With GTRR, a single line GTRR step simply does nothing--leaving you right where you started. If, however, your script is then written to do other things with this record--such as deleting the found set, you must provide additional checking or your script can screw up your data.

                    None of this refers to your script at all.

                    For those interested in learning more about Go To Related Record: 

                    The Complete Go To Related Record

                    • 7. Re: Finding a record with a script
                      StefaanVerschelde

                      @Sorbsbuster: You wrote: "Let's say the relationship to the portal is called customer_Projects (a good nomenclature system to use)."

                      Where can I find the name of the relationship or is this standard in Filemaker that a portal gets the name of the layout followed by an underscore and the name of the table on which the portal is based?

                      Thanks and sorry to bother you with this minor issue.

                      • 8. Re: Finding a record with a script
                        Sorbsbuster

                        If you only have two tables ('Customers' and 'Projects') then you will be able to simply create a relationship between those two tables, and call each from the other.  The relationships are called what the end table is, so in that case each will be called simply 'Customers' and 'Projects'.

                        But you should really duplicate the Projects Table (in the Relationships Graph) and then link to it from the Customer Table.  You re-name the second occurance of the Projects Table 'customer_Projects'.  Strictly, the boxes on the Graph are 'Table Occurances' and are used to define unique relationships between the basic tables in your file.  So your Relationship Graph would look like:

                        CUSTOMERS ---------By ProjectID --------< customer_Projects

                        PROJECTS

                        It makes no functional difference which way you do it, and in this case no administrative difference either, but believe me: as your file grows using this type of structure will transform it into 'Really Easy' out of 'Utterly Unmanageable'.

                        That is just one way to structure the relationships, and is my preferred method, but there are others.  Certainly pick one of the tried-and-tested.  For a better explanation, try the links here: http://forums.filemaker.com/posts/1c39ff199a

                        • 9. Re: Finding a record with a script
                          StefaanVerschelde

                          @Sorbuster: I am terribly sorry being a complete Filemaker nerd but, i can't manage to find the way to enter your script as I always get into the dutch version of the way to enter a script.

                          I renamed the duplicated table and this works, which means that the portal is based on a duplicate of the table with the project link at the customertable and so you can define the ProjectID from the duplicate table.

                          Now when I try to write the script, I always get into the standardised method by filemaker, using predefined definitions and as they are in dutch , tour script makes it very difficult.

                          How do I finaly get the F....ing script to work in my database.

                          Is there a good training online for using scripts?????

                          HELP!!!!!

                          • 10. Re: Finding a record with a script
                            Sorbsbuster

                            I think we're only into a translation issue.  How can I best help you with the key steps? -

                            Set Variable [$ProjectID ; customer_Projects::ProjectID )

                            Go To Layout [Project Form View ]

                            Enter Find Mode

                            Set Field [ProjectID ; $ProjectID ]  <-- make sure you pick up the  field from the Projects Table at the top of the  dialogue box

                            Perform Find

                            We should be able to figure out this one!

                            • 11. Re: Finding a record with a script
                              StefaanVerschelde

                              @Sorbuster: Thanx Sorbuster, it works fine now, but I had to do it in a different way. I got the idea behind the solution and started to analyse what you said. Everything works fine!!!!! Many thanks and if I need some more information, you will be the first to hear about it ;-)