9 Replies Latest reply on Aug 7, 2014 2:48 PM by philmodjunk

    Question on how to alert when user enters data

    terrypink

      Title

      Question on how to alert when user enters data

      Post

           Hi everyone,

           Wondered if someone can help me?  I'm kind of new to Filemaker and I have created a database that works off of Filemaker GO so that users can fill out information on a table called Diary from their phone.  The database is stored on a Filemaker Server.

            

           My question is, is there a way to create a script that can send an alert to a particular email address if the user of the phone app doesn't fill out information from their Diary table for a certain amount of time (if they haven't filled anything out for the last 24 hours)? 

            

           On a similar note, if such a script is too difficult, is there a way to create a report that shows that user's answers for the day, but can this report be sent out automatically to an email address rather than having the Filemaker developer create a report each day?

            

           And if the answer is yes to either question, is there an example of such a script somewhere?

           Thank you so much!
           ~Terry

        • 1. Re: Question on how to alert when user enters data
          philmodjunk

               The filemaker developer should never, ever have to create a report each day. A user might perform a script to pull up the records needed for a report, but that's not the same thing as creating a report.

               To answer your original report, a server schedule can perform the same script once a day. That script can perform a find to find all records for users that have not entered any records in the Diary table in the past 24 hours.

               The list of such users can be put in the body of an email that can be emailed from the server using the SMTP server option.

          • 2. Re: Question on how to alert when user enters data
            terrypink

                 Thanks, Phil.  Can you provide some additional instructions on how to create such a server script?  Are there any resources or examples anywhere?

                  

                  

            • 3. Re: Question on how to alert when user enters data
              philmodjunk

                   How is your database set up? Do you have one table of users, one record for each user linked by an ID to a table of Diary entries? Is each Diary entry a separate record? Is there a date field that records when a diary record was created?

              • 4. Re: Question on how to alert when user enters data
                terrypink

                     I don't know how to create a table of users, with each record linked by an ID to a table of Diary entries?

                      

                     Yes, each Diary entry is a separate record.

                     Yes, there is a timestamp field that records when a diary record is created.

                      

                     Is it easier to create a report that then automatically gets sent to  a particular email everyday?

                • 5. Re: Question on how to alert when user enters data
                  philmodjunk

                       How does each user only see their diary entries? Is there a field that identifies each user?

                       Is each diary entry a separate record or does the user add data to previous entries all in the same field?

                       You really need that table of users as a way of determining which users have not made a diary entry in the specified time interval. You are using a relational database so setting up a table of users linked to your diary entries is a basic level task you need to learn how to set up. I recommend that you find and invest in some training in FileMaker and relational database design.

                       What you need is this:

                       Users---<Diary

                       Users::__PkUserID = Diary::_fkUserID

                       For an explanation of the notation that I am using, see the first post of: Common Forum Relationship and Field Notations Explained

                       With that set up, you can add a calculation field, cLastEntryTS, defined as:

                       Last ( Diary::CreationTimeStamp )

                       Your script can then use a scripted find similar to those found in this thread: Scripted Find Examples

                       To find all User records where the cLastEntryTS is less than Get ( CurrentTimeStamp ) - 24*3600. (24*3600 is the number of seconds in 24 hours)

                  • 6. Re: Question on how to alert when user enters data
                    terrypink

                         Thank you again, Phil.  Is there a way to to email all these records to a particular email address?  what would the script look like for that?

                    • 7. Re: Question on how to alert when user enters data
                      philmodjunk

                           I can think of several interpretations of "email all of these records". What I had in mind was to list the names of the users that did not post a diary entry in the body of the email. That can easily be done with a calculation--especially in FileMaker 13 where there's a new "list of" summary field that can list the values of a field from every record in your found set.

                           There are some unfortunate limitations to what you can do "server side" so if you want to do more than, such as attaching a PDF report or a snapshot link to the email, you'd have to run the script from a FileMaker client. That can still be automated to happen once a day, but it takes more setting up and details depend on the OS of the client machine where you'd set this up.

                      • 8. Re: Question on how to alert when user enters data
                        terrypink

                             What would be the script to attach the list of names of users who did not post an entry in the the diary in the body of the email?

                        • 9. Re: Question on how to alert when user enters data
                          philmodjunk

                               That depends on the version of FileMaker that you are using.

                               With FileMaker 13, you can define sUserNameList as a summary field and select the new "list of" summary field.

                               Once your script has performed a find for those users and determined that at least one such user was found, you can put something like this into the body of your email using the send mail script step:

                               "The following personnel did not post a Diary entry during the previous 24 hours" & "¶¶" & sUserNameList