4 Replies Latest reply on Jun 1, 2010 2:31 PM by exboroboy

    find name and send report

    exboroboy

      Title

      find name and send report

      Post

      Hello hopefully someone can help me.

       

      I am trying to write a script that looks at my database finds a name then sends a email to that person showing the report that it has found for that individual. 

       

      Now I know I can program file maker with the name of each person in the script and have it work its way down the list and send the email as an attachment. However if the user adds a new name this needs to be added into the script. Is there a way I can do this so it just sends an email to the first found name and once its sent then goto the next name etc also to show the report in the email and not as an attachment?

       

      Thanks very much in advance

       

      Scott 

        • 1. Re: find name and send report
          philmodjunk

          Can't really go into specifics without knowing more about your database.

           

          Do you have a table where there is just one record for each email recipient?

          If so, you can add a data field to that table and format it as a check box field.

          Create a layout that lists all the potential recipients and this check box field.

          The user can then select recipients by clicking their check box field.

          A script can then find only the records where the check box is selected and cycle through this list of records in a loop emailing each person in turn.

           

          You can only include plain text in a filemaker generated email--so you won't be able to include the report in the email body unless you can do so with plain text or if you purchase an email plug-in with greater capabilities.

          • 2. Re: find name and send report
            exboroboy

            Thanks for the quick response Phil. I dont think I explained myself very well.

             

            Here is the script Im trying todo

             

             

            Go to Layout [ “Holidays This Period” (approval) ]
            Set Error Capture [ On ]
            Loop
            Perform Find [ Specified Find Requests: Find Records; Criteria: approval::time off email sent Yes No: “=YES” ] [ Restore ]
            If [ Get ( LastError ) = "401" ]
            Replace Field Contents [ approval::time off email sent Yes No; Replace with calculation: "No" ] [ No dialog ]
            Go to Layout [ “booking_detail_week_1” (booking_detail_creation) ]
            Show All Records
            Exit Script [ ]
            Else
            Enter Find Mode [ ]
            Set Field [ booking_detail::name; "Judith Fahie" ]
            Set Field [ booking_detail::booking_type; "Holiday" ]
            Set Field [ approval::time off email sent Yes No; "No" ]
            Perform Find/Replace [ ] [ No dialog ]
            Save Records as PDF [ File Name: “file:absence”; Current record ] [ Document - Compatibility: Acrobat 7 and later ] [ Pages - Number Pages From: 1; Include: All pages ] [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ] [ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ] [ Restore; No dialog ]
            Send Mail [ Send via E-mail Client; To: Personnel Records 2::Email; Subject: "Your Holidays So Far"; Attachment: “file:absence” ]
            Set Field [ approval::time off email sent Yes No; "Yes" ]
            #Next Person
            Enter Find Mode [ ]
            Set Field [ booking_detail::name; "Mike Butts" ]
            Set Field [ booking_detail::booking_type; "Holiday" ]
            Set Field [ approval::time off email sent Yes No; "No" ]
            Perform Find/Replace [ ] [ No dialog ]
            Save Records as PDF [ File Name: “file:absence”; Current record ] [ Document - Compatibility: Acrobat 7 and later ] [ Pages - Number Pages From: 1; Include: All pages ] [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ] [ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ] [ Restore; No dialog ]
            Send Mail [ Send via E-mail Client; To: Personnel Records 2::Email; Subject: "Your Holidays So Far"; Attachment: “file:absence” ]
            Set Field [ approval::time off email sent Yes No; "Yes" ]
            #Next Person etc
            End If
            End Loop

             Now what I'd like todo is not have to enter each persons name and for Filemaker to just find them, so if a new member of staff is added I dont have to add this to the script. All these records are contained within the same table.

            Thanks once again for your help

             

            Cheers

            Scott

             

             

            • 3. Re: find name and send report
              philmodjunk

              Whether you run the script against all the people on your list or just selected people as I described the basic principle is the same.

               

              Do you have a table that lists all personnel each one in a separate record?

               

              If so, you can loop through this table performing one find for each person in the table. You can then control who get's emailed simply by adding/removing records from this table.

               

              Here's a general outline of the script:

               

              Go to Layout ["Personnel" (Personnel)]

              Show All Records

              Go To Record/Request/page [First]

              Loop

                 Set Variable [$Name ; Value : Personnel::Name ]

                 Go to Layou [ "booking_detail_week_1]

                 Enter Find Mode []

                 Set Field [booking_detail::name; $Name]

                 //set your other criteria

                 Perform Find [] //Not perform find/replace

                 Save as PDF

                 Send Mail

                 Go To layout ["Personnel" ( Personnel) ]

                 Go to Record [next ; exit after last ]

              End Loop

              • 4. Re: find name and send report
                exboroboy

                Thank you very much Phil your a life saver. 

                 

                It works like a charm