5 Replies Latest reply on Feb 22, 2012 9:51 AM by philmodjunk

    Auto Email when record field value is 0

    ShaikhAtta1238

      Title

      Auto Email when record field value is 0

      Post

      I am using a field COUNTDOWN Calculation in a global field End Date - Get(CurrentDate) and i have many records like these in the table and the database is working on a FM Server. Now what script will i write in the database  so whenever any records COUNTDOWN field becomes 0 an email is automatically sent to a specific email (xyz@email.com)

        • 1. Re: Auto Email when record field value is 0
          philmodjunk

          You can perform a find for 0 in this field, but the find will search an unstored field and this will not be as fast as searching End Date for all records with the current date which will find the same records, but avoid searching on the unstored field.

          Enter Find Mode []
          Set Field [YourTable::End Date ; Get ( CurrentDate ) ]
          Set Error Capture [on]
          Perform Find []

          will bring up your found set of all records where the count down = 0 and then you can loop through the found set to send individual emails or you can send just one email with either a list of data from the resulting found set included in the body or an attached PDF of a report listing the records from the found set.

          • 2. Re: Auto Email when record field value is 0
            ShaikhAtta1238

            Thanks Phil for the quick response. The records of this table will be defined once in a year and they will automatically work throughout the year with different deadlines. Let me show you how is the layout table. I forgot to mention that there is a field which will check if the report is submited and will add a value of 1 in the RECEIVED field and if the DAYS REMAINING is reached to 0  it will check if the RECEIVED field is 0 only then will send the email other wise will not email.

            Report                    ---                Due date    ---       Days remaining --- Recevied 

            Project Document                 25/02/2012                3                         0

            Budget Summary                 27/02/2012                5                         0

            Visit Report                         30/02/2012                8                         1

             

             

            • 3. Re: Auto Email when record field value is 0
              philmodjunk

              Enter Find Mode []
              Set Field [YourTable::End Date ; Get ( CurrentDate ) ]
              Set field [YourTable::Received ; 0 ]
              Set Error Capture [on]
              Perform Find []

              This finds all records with today as the due date and for which Received also = 0.

              • 4. Re: Auto Email when record field value is 0
                ShaikhAtta1238

                thanks Phil I know I might be asking some silly questions but thats due to my start in FM. Where am I going to place the script. 

                • 5. Re: Auto Email when record field value is 0
                  philmodjunk

                  How do you want these checks made?

                  You can put a button on a layout and run the script when you choose to do so.

                  You can use file options to run the script every time the file is opened.

                  You can use a server schedule to run the script once a day (use SMTP for the emails)

                  You can use a robot file with an operating system based scheduler to run this script once a day.

                  You can open a window and leave it open 24/7 with an Install OnTimer script setting up a timer to perform the script once a day or some other specified interval.