13 Replies Latest reply on Aug 12, 2016 2:03 AM by Ben_B94

    Perform Find from Popover

    Ben_B94

      Hi I have these 3 tables,

      a layout based on training course has a popover with global fields. One such is g_Name, which I have put as a drop down list of Staff::Name. I want to check if what is either entered or selected in this field exists as a Staff::Name in the staff table. So what I'm asking is how best to perform the find.

       

      As part of the script , to find, I'm currently doing,

       

      But it never seems to find a match, even when the value of g_Name is from the drop down list I mentioned earlier which is made up of values from the staff table.

       

      Thanks in advance

        • 1. Re: Perform Find from Popover
          twelvetens

          You don't really need to do a search here, you could use a relationship based on the gName field in Training Course, matched with the Name field in the Staff table, and then Count how many records in the child table exist based upon that relationship. This allows you to then use that number for Conditional Formatting / Hiding / Display etc etc...

          1 of 1 people found this helpful
          • 2. Re: Perform Find from Popover
            philipHPG

            The layout context is very important for the Find here. If you are on a Training Course layout, then the Find you mentioned is actually looking for Training Courses that were attended by the Staff name in g_Name. If the Staff person never attended a course it will not return any results (regardless of whether the Staff person exists or not).

             

            If you want to find Staff independent of Training Courses, you need to switch to a layout based on Staff, or use another approach. Since you mentioned that you are using a drop-down list, using a Find to verify that they exist is redundant. Let us know more about what you want to do through this Find and we might be able to help you more.

            • 3. Re: Perform Find from Popover
              Ben_B94

              I should possibly have posted my script as well, but before the above find is carried out the first thing I do is switch to a staff layout.

               

              What I'm trying to do is to check whether or not the person exists. If they do already exist then grab the ID and set it = to staff_join::Staff_ID. My hope is once this is done staff fields will autofill on a layout based upon staff join. 

              • 4. Re: Perform Find from Popover
                philmodjunk
                What I'm trying to do is to check whether or not the person exists. If they do already exist then grab the ID and set it = to staff_join::Staff_ID. My hope is once this is done staff fields will autofill on a layout based upon staff join.

                Is it really the find that isn't working or is possible that this second part of the process is failing and thus creating the impression that your find didn't work?

                 

                What you describe, go to staff layout, then perform the script fragment in your original post, should work and is a basic method used throughout Many FileMaker Apps.

                • 5. Re: Perform Find from Popover
                  philipHPG

                  Perhaps if you post the full script we can figure out what is going on.

                   

                  However, if you are already using a drop down based on staff name, you already have access to the staff ID through that (set up the drop-down to use the ID but display the Name)

                  • 6. Re: Perform Find from Popover
                    Ben_B94

                     

                     

                    Commit script

                     

                     

                    The pause script part in the if statement is to give time to let someone fill out the details of a person before it continues. I know this really not reliable so please show me a better way.

                    • 7. Re: Perform Find from Popover
                      philipHPG

                      The biggest issue I can see is in your Commit script - on the first line you set $staffmemberID to Get ( RecordID ). Using RecordID is not a reliable way build a relationship. You should probably set the variable to Staff::Staff_ID. Then you might find it works better.

                       

                      Also, you have a redundant Go to Layout ["Staff" (Staff] after performing the Find and the Close Popover at the end is also unnecessary as changing layouts will automatically close the popover.

                      • 8. Re: Perform Find from Popover
                        philmodjunk

                        If you temporarily insert a halt script immediately after "perform find", do you find the staff member thus selected?

                         

                        Looks to me that your script to find records is working and as I previously suggested, it's the rest of the script that has a problem.

                         

                        I never, ever link records using FileMaker's internal record ID (Get ( RecordID) ). Simply importing these records from one copy of your file to another (say after a mishap damages your working copy) can assign new and different ID's to the records during the import.

                         

                        Use either an auto-entered serial number or a text field that auto-enters the calculation: Get (UUID) to generate unique ID's in a table and then use that field as a match field in relationships as needed.

                         

                        You might want to examine this demo file. I has carefully and copiously documented examples of different enhanced value selection techniques--including one similar to what you describe here where you want to either select an existing record, or if there is no such record, create one.

                         

                        Adventures in FileMaking #2 - enhanced value selection

                        2 of 2 people found this helpful
                        • 9. Re: Perform Find from Popover
                          philipHPG

                          As for your pause for 60 seconds, yes that is not very reliable (as someone who is distracted by a phone call, for example, might not complete the necessary information before the script takes over).

                           

                          Here are two options for dealing with it:

                           

                          1). You can Pause the script indefinitely, the user will see a Continue button that will continue the script. This requires minimal change to your script, but relies on the user understanding how the system works.

                           

                          2). Preferably, break it up into two scripts, and when the user completes the Staff info they click on an "OK" button which then calls the second part of the script.

                           

                          There are other options as well.

                          2 of 2 people found this helpful
                          • 10. Re: Perform Find from Popover
                            dtcgnet

                            When you go to the Staff layout, you show all records, then enter find mode. No need to show all records, and it will actually degrade performance. The find will search all records whether they're displayed or not.

                             

                            If you have FMP Advanced, use the Data Viewer to see what the value of Training Course::g_Name is right after the "Perform Find" step. If you don't have FMPA, then add a Show Custom Dialog step which shows the value of Training Course::g_Name. I'd consider adding a Commit Records step right before the Go to Layout [ "Staff" (Staff) ] to ensure that the selected value has actually been committed and entered into Training Course::g_Name.

                            • 11. Re: Perform Find from Popover
                              Ben_B94

                              Hi, it does indeed find the correct record, thanks for the file I will read it thoroughly.

                              • 12. Re: Perform Find from Popover
                                Ben_B94

                                Thanks, I will try break it up further using multiple scripts instead of using a timer.

                                • 13. Re: Perform Find from Popover
                                  Ben_B94

                                  One of my mistakes was thinking Get(recordID) and Staff_ID were the same thing. Get record ID says returns unique ID number of the record which I was thinking, great that must mean the Staff ID of the record which is what I wanted. I didn't realize there is another internal ID created.