2 Replies Latest reply on Apr 22, 2015 9:57 AM by tmslayton

    Finding records with a script to send an email

    tmslayton

      Hi,

       

      I am sure this is a newbie question (as I am). I am trying to prepare an email using the Send Mail script step to send to multiple recipients in a single email.

       

      The relationships in the data look like this

       

      Reminders ->

           Program ->

                ProgramStaff => (This table holds multiple records between program and staff)

                      Staff

       

      On the reminder layout I have a button to send an email. I have the Send Mail options set to the following.

       

      Send Via: Email Client

      Create:  One email using data from the current record

      To:  Staff::StaffWorkEmail

          Collect addresses across found set: checked.

       

       

      Shouldn't FileMaker find and create a string of email addresses from the Staff table using the relationship of ProgramStaff? My expectation in test case that I'd get a string with two email addresses as I have two entries in the ProgramStaff.

       

      When ever I click the button I only get one email address.

       

      Very Best,

       

      Tom

        • 1. Re: Finding records with a script to send an email
          erolst

          Tom –

          I am sure this is a newbie question (as I am)

          as were we all. Anyway …

          To:  Staff::StaffWorkEmail

           

          … what you need to know here is that a reference to a related field by default returns data from the first related record, via the (explicit or implicit) sort order for the relationship between your current context and the reference target – Reminders … Staff, in this case.

           

          If you want a list of the addresses, you need to tell FM so, e.g. by using

           

          List ( Staff::StaffWorkEmail )

           

          or, for use in an address field, probably

           

          Substitute ( Staff::StaffWorkEmail ; ¶ ; ", " ).


          And you can uncheck “Collect across found set”, because your found set in that moment is in reminders, which don't have addresses.

           

          Another way would be to first GtRR, i.e. use the step

           

          Go to Related Record [ Staff ; matching current record only ]

           

          travelling the relationship chain as outlined above; now you could use “Collect across found set”, because the found set is the list of recipients.


          Be aware, though, that if this cardinality is true (where many >-- one) …

           

          Reminders >-- Programs --< ProgramStaff >-- Staff

           

          … you would lose the context of the reminder you started out on, because none of the found Staff records can be uniquely associated with any reminder; OTOH, you could capture the relevant reminder data in $vars (title, date, body etc.) before you change the context with GtRR, and pass those to the options of the Send Mail step.

           

          Hope this is clear as mud …

           

          Oliver

          • 2. Re: Finding records with a script to send an email
            tmslayton

            I used the List() function and both addresses auto-magically appeared. Thank you for your help!!