1 2 Previous Next 19 Replies Latest reply on Aug 26, 2014 11:06 AM by TimCranwill

    Perform find does not work on a script?

    TimCranwill

      Title

      Perform find does not work on a script?

      Post

           I'm wondering if each line of this perform find has an "OR" in-between them? how does this exactly work? I used the script with the script debugger and it works fine but when other people enter records it gives me false positives.

      Specify_Find_Requests_at_1.45.52_PM.png

        • 1. Re: Perform find does not work on a script?
          philmodjunk

               Yep. You have 5 find requests here. The logic of what you have specified here is that FileMaker finds all records that match the criteria of Request 1 OR Request 2 OR Request 3 ...

               You may find the approach to scripted finds illustrated in this thread an easy way to script the find process: Scripted Find Examples

          • 2. Re: Perform find does not work on a script?
            TimCranwill

                 Thanks for the quick reply! As i said when i step through it with script debugger and watch the data viewer it works like a charm, BUT as records start rolling in from Filemaker Go users Im getting a lot of false positives? I can tell bc im getting smtp emails I shouldn't be.

            • 3. Re: Perform find does not work on a script?
              philmodjunk

                   But you asked if the logic was "Or" so I answered that part of your question.

                   You'll need to look at the actual criteria being used when the script executes. For example, you can run the script and then use Modify Last Find to return to find mode and examine the criteria. While in find mode, you can navigate between requests on your layout just like you would records in Browse mode to see all of the specified criteria.

                   You do mention emails in your last post. Specifying search criteria in an email address field can be tricky. The @ symbol is a special search operator and thus using the following two example criteria will not produce the same results:

                   SomePerson@SomeDomain.com

                   "SomePerson@SomeDomain.com"

                   In the first example, FileMaker interprets the @ to represent "any one character". In the second, the enclosing quotes cause filemaker to treat it like any other character specified as find criteria.

              • 4. Re: Perform find does not work on a script?
                TimCranwill

                     Sorry, Im not explaining myself very well.

                     Here is another attempt at getting the correct found set in order for the auto SMTP emails can be sent out. As i step through this script via script debugger it works perfectly, but as soon as other filemaker go users enter records, for some reason ignores the $clientR variable and i get emails that i shouldn't. ie. clients from the employee layout that do not match that variable.

                • 5. Re: Perform find does not work on a script?
                  TimCranwill

                       Im also interested in having this script run on the server, but i can't get the emails to fire when i use "perform script on server". Keep in mind that i have my files hosted on a shared filemaker 13 server, so I have limited access to configurations.

                       I also need to add operators to the set field calculation. Unsure about the syntax. ???

                  • 6. Re: Perform find does not work on a script?
                    philmodjunk

                         Notice that you are on a layout based on the Employees table occurrence but your script specifies criteria in what is presumably a related table occurrence named Auto Email Client.

                         In this context, that instructs FileMaker to find all Employees records that have at least one related record in Auto Email Client that matches the specified value in your variable. I don't know what relationship you have between Employees and Auto Email Client, but that suggests that you may be finding records that you don't expect to find because you may have more than one related record in Auto Email Client, one that matches the specified criteria, but others that do not match. You examine the data in Browse mode after the find and see records where there appears to be a failure to match on this field because you may see data from one related record while the fine criteria matched to data in a different record that is related to the same employee record.

                    • 7. Re: Perform find does not work on a script?
                      TimCranwill

                           In that case would it make sense to go to layout "auto email client" perform a find, then go to "employee" table and extend the find? Or is that even possible?

                      • 8. Re: Perform find does not work on a script?
                        philmodjunk

                             If you perform a find on auto email client and then just change layouts to one based on employees, the found set on the employees layout will not in any way be affected by the find performed on the previous layout. Each, due to being based on different table occurrences, has its own independent found set of records.

                             How to fix this is a question that I am unable to answer with confidence based on the information available to me at this point.

                             What is the relationship between these two tables? What does a record in auto email client represent?

                             What is your scripted find intended to find?

                        • 9. Re: Perform find does not work on a script?
                          TimCranwill

                               I created the table auto email client so that i can use a portal in the employee table that would compile a list of clients that employees could use to add clients they wanted auto emails sent to them once a report was created that was based on that client.

                               So from the rounds table where the initial record is created set variables, go to employee and search those portal rows and find which employees have that clients name in their portal.

                               the script is comparing the record created in the rounds table that always contains a client's name with the values in the portal rows "auto email client" that resides on the employee table.

                               I hope this screen shot helps.

                          • 10. Re: Perform find does not work on a script?
                            TimCranwill

                                 here is a screen shot of the portal created using "Auto email client" table that resides on the "employee" table.

                            • 11. Re: Perform find does not work on a script?
                              philmodjunk

                                   I just spent some time reviewing your original scripted find and am puzzled by what I see.

                                   Each record in Rounds links a specific client to a specific employee.

                                   Aren't Rounds::Medication, Rounds::Psychological State, Rounds::Mental Status, and Rounds::environment details data that describes the client?

                                   If so, why does your find search for this data in the employee table rather than the client table? Clearly there are multiple clients linked to a single employee so I don't see the connection here between a client's mental status, for example and the value of Mental Status in the Employee table.

                              • 12. Re: Perform find does not work on a script?
                                TimCranwill

                                     Im sorry, im not providing enough info.

                                     From the top...

                                     As the employees interact with the clients they submit rounds records. In the rounds records they enter client name, psychological state, mental status, environment, ect via value lists. Every time a record is committed the script fires.

                                     Employees want to, instead of querying the db, auto emails sent to them based on different values entered in the rounds records but for only certain clients and certain criteria from the rounds record, again so they don't have to actively search the database.

                                     So...

                                     I mirrored in a way what is collected during rounds onto the employees table via check boxes and a portal so that each employees can "sign up" by clicking a check box or adding clients to the portal,  so i can compare rounds records to employee records and find matches, that way compiling a found set and sending out emails via smtp mail server.

                                      

                                • 13. Re: Perform find does not work on a script?
                                  philmodjunk

                                       Yes, but that still does not explain why data about the client is being searched for from fields in the employee table.

                                       Say the employee sees two patients and notes a mental status of "depressed" on one student and "manic" for another. Why does the script search for a mental status of either "Manic" or "depressed" in a field recorded in the employee table? That looks like data to be searched out from the records in Rounds, not Employees as you wouldn't record data about the client in the employee record and if you could, how could you record multiple values for multiple clients in the employee table?

                                       What I am missing here?

                                  • 14. Re: Perform find does not work on a script?
                                    TimCranwill

                                         Its searching the employee table for matches between the round records and employee records bc i need a found set of employee emails.

                                         If it searched the rounds records i wouldn’t get a found set of employee email addresses.

                                         To simplify I’m going to give you a simplistic version of events.

                                         employee visits a client
                                         once the visit concludes he enters a round record.
                                         first field is client name, employee enters steve via value list in a drop down of all clients.
                                         second field is his mood, employee enters 3 via value list in a drop down with options 1-5.
                                         commit record variables are set
                                         client name=  $steve
                                         client mood = $3

                                         go to employee table
                                         portal set up to add rows of client names
                                         checkbox set from value list 1-5

                                         if any employee has added steve to his or her portal.
                                         and the check box for mood is set to 3.
                                         then we have a match and he or she is added to the found set
                                         otherwise we don’t and that employee doesn’t get an email about steve.

                                    1 2 Previous Next