5 Replies Latest reply on Jul 10, 2015 6:32 AM by TSGal

    Auto-Add to Reminders and Calendar

    Ryusui

      Title

      Auto-Add to Reminders and Calendar

      Post

      Greetings, all.

      I have been researching for a few weeks now with few results, so hopefully someone here might be gracious enough to help me out.  I have an event database that, after setting the event date for the new record, will auto-populate a number of fields with due dates for a bunch of different tasks.  My understanding is that I should be able to use AppleScript for this, but I have not been able to figure out how.

      My first question: is there a way to have Filemaker add an event to my Mac Calendar once I set the event date and start and end times in the record?  I'd like it to be added to a particular calendar - that is, the "Business" calendar in the Calendar app - with a predetermined format that is a mix of static text and info from fields.  So for example, when it adds the event date and time to my calendar, the event would be titled:
      EVT: [FIELD1] & [FIELD2]

      In addition, is there a way to have the new calendar event set the "location" field in the Mac Calendar app utilizing one or more of the fields?  So if it has one location, it would just insert that location in the the Mac Calendar location field.  If it has 2 or three, it would be like:
      [LOCATION1] / [LOCATION2] / [LOCATION3]

      Finally on the calendar topic, I need to make sure that if I change something like the times or location(s), that it auto-updates the calendar event once I validate the field.  Or if I mark the event as "INACTIVE" (they have three statuses: ACTIVE, INACTIVE, COMPLETED) that it removes the event from the calendar completely.


      For reminders, as mentioned my record contains a task list that will auto-populate due dates based on when I choose the event date.  Once these fields have their dates auto-populated, I want it to automatically create reminders for each one of the task items in the "Business" reminder list of the Mac Reminders app.  Again, it needs to have a set format so that if I have 30 events going on at once, I know which task is for which event.  So maybe something like:
      [EVENT NAME FIELD]: [INVOICE DUE FIELD]
      [EVENT NAME FIELD]: [LAYOUT DUE FIELD]
      And so forth.  Also, my tasks don't have due times, but is there a way, upon auto-export to the reminders, that I can tell it to set them all to the same due time?  Say 10am?

      Lastly, can this sync two-ways?  So if I delete the task from the Reminders app, or mark it as complete, it will delete the date from the field, or mark the task complete in the database record?  Or if I delete the date from the record's field or mark that field as complete, that it deletes the reminder from the app or marks it as complete.

      For the task list, I have a checkbox list that has a box connected to each one of the task fields.  If a field is past due, the field's title will show in red.  If I click on that field's checkbox, or if I delete the date from the field, the field title will revert back to black.

      I hope someone can either assist me or direct me to a link I can accomplish a task that has been haunting me for a while.  Thanks for your time!

        • 1. Re: Auto-Add to Reminders and Calendar
          Ryusui

          Of course it figures that when I finally break down and ask for help on a forum, I finally stumble across some of the answers I've been looking for.  I finally figured out what AppleScript is needed to have FileMaker create a Reminder item and a Calendar event.  But there are still a few hiccups.

          Firstly: I managed to add a button to my database that will create a new Reminder item for me:
          List (
          "tell application " & Quote ( "Reminders.app" ) ;
            "set mytitle to " & Quote ( Events::event_name & ":" & " " & "Invoice Due" ) ;
            "set mybody to "& Quote( Events::notes ) ;
            "set mydate to date " & Quote ( Events::date_due_invoice ) ;
            "set mylist to list " & Quote ( "Business" ) ;
            "tell mylist" ;
              "make new reminder with properties {name:mytitle, body:mybody, due date:mydate}" ;
            "end tell";
          "end tell"
          )

          This works without fail.  If I hit the button, a Reminder item is created in the right list with all the info I asked for.  But now I am not sure how to automate this when the "date_due_invoice" field is auto-populated after choosing the event's date.

          The first thought I had was to create a script to run multiple AppleScripts when the event date is chosen and the field is validated.  But this presented a problem - being that the script runs before the various task fields have a chance to auto populate, I get "invalid date" errors because the script is, of course, trying to pull dates from fields that have no dates yet.  Though if I go back into the field after the date has been chosen, then re-validate it, it will run the scripts just fine and enter the Reminder items into the app.  Obviously this is not an ideal way to do this.  And I haven't yet figured out a way to run the script after the task fields have been populated.  So I'm stuck here.

          This also brought up another problem - if I happen to validate the field again after the Reminder items have been added, it will add them yet again.  So I end up with duplicates.  Is there even a way for Filemaker and Reminders to talk to each other bi-directionally so that I don't get duplicates created?  Or to have a Reminder item updated if I change the date in one of the task items as opposed to creating a second Reminder item with the new date?  Even if it can delete the first one when creating the new one, that would be acceptable.

          I also managed to add a button that adds an event to the Calendar.  And while this script can be run after validating the event date field, I am still left with the issue of duplicate events if I ever re-validate the date field, as well as trying to change or delete the old event if the date changes.

          • 2. Re: Auto-Add to Reminders and Calendar
            Ryusui

            Just wanted to give my topic one bump to see if there's a chance for some aid.  Thanks, all.

            • 3. Re: Auto-Add to Reminders and Calendar
              TSGal

              Yukio Kina:

              Thank you for your posts.

              For the "date_due_invoice" field, use an OnObjectModify script trigger or OnObjectValidate script trigger.  That is, once the date is entered (and validated) and the field is exited, a script will execute.

              TSGal
              FileMaker, Inc.

              • 4. Re: Auto-Add to Reminders and Calendar
                Ryusui

                Thanks for your response, TSGal.

                I added the script as you recommended, but it does not add the reminder.  Keep in mind that the "date_due_invoice" field does not have the date entered manually, but it auto-calculates based on the chosen date for the event.  So for example, if I type "12/10/2015" into the "date_event" field, then "date_due_invoice" will automatically populate with "11/10/2015".  So the "date_due_invoice" is never entered into by me.

                Also, how do I link the reminder or calendar entry in the Mac app to the Filemaker database record so that I can modify it without creating duplicates?

                • 5. Re: Auto-Add to Reminders and Calendar
                  TSGal

                  Yukio Kina:

                  Use the script trigger on the "date_event" field as this will trigger the calculation.  You can then use the result of the calculation for the reminder.

                  I don't know what information you are retrieving from the Reminder application.  There is probably a key field that you can then populate a database field.  That way, if the database record is updated with a new date, you can look up the ID in the Reminder application and make the necessary changes.

                  TSGal
                  FileMaker, Inc.