Automator workflow triggered by Calendar event runs unexpectedly

I have set up an AppleScript within an Automator workflow to download a file from a web site and save it to iCloud as a backup. The workflow works fine when run independently. I set up two Calendar events to trigger opening the Automator file saved as a Calendar Alarm, one at 07:00 and another at 22:00 as a daily repeating event. While the file is opened consistently at the designated alarm times it also gets opened about 40 minutes after the designated times and also at midnight. Part of the AppleScript sends an iMessage documenting the date and time of the completion of the workflow.


So rather than two file openings Calendar seems to trigger five openings. This same workflow file used to get triggered by Calendar correctly using an Intel Mac mini running Catalina but since migrating to an M1 Mac mini running Monterey 12.2.1 there are the five triggerings each day.


Anyone having a similar experience?

Mac mini, macOS 10.15

Posted on Feb 25, 2022 5:25 AM

Reply

Similar questions

8 replies

Mar 26, 2022 10:12 AM in response to paulcrawford

Paul, I have done a bunch of tests on this issue and have found the bug to be rather subtle. In my case, what is required is BOTH for the AppleScript in the Automator action to load an external script AND for the script to trap and ignore an error. The script contains a 'try_on error_end try' block. An error occurs in the 'try' section and is trapped and ignored in the 'on error' section. To see if some kind of timeout was involved I have tried time delays in both the external script (to simulate a website access or file download) and as a 'Pause' Automator action in the Calendar Alarm. Time delays had no effect on causing or fixing the extra Calendar Action trigger.


I will now go ahead with the bug report to Apple. Thanks for the instructions on that. I hope this is helpful for you.


Here are snippets for the AppleScript Automator action and external script handler:


Automator ‘Run AppleScript’ in Calendar Alarm

on run

say “Running calendar alarm”

set testHandler to load script alias ‘my script file spec’

tell testHandler to doIt()

end run


Loaded script:

on doIt()

set myDate to current date

set theMsg to myDate as text

display notification theMsg

try

set x to 1 / 0 -- deliberately trigger error

on error

set x to 1  --  ignore the error

end try

end doIt

Mar 24, 2022 6:37 AM in response to steveBinLA

I have just submitted a bug report on this issue. You can submit one as well by going to https://feedbackassistant.apple.com where you will need an Apple ID to log in. In the top bar of the page click on the Compose New Feedback button and then fill in the required information.


My submission showed that there were no other similar reports, so if you do one it should help with the priority.

Mar 23, 2022 6:37 PM in response to steveBinLA

After deleting the existing events, I created another two new events with the same file open alert. For the last five days I have been getting a second trigger on both events about two or three minutes after the real event alert trigger plus one additional trigger at midnight for a total of five each day when there should only be two. I agree that it must be a bug. Have you reported it to Apple?

Mar 26, 2022 12:19 PM in response to steveBinLA

Thanks for the update and explanation of your testing. My Automator Application file has just one 'Run AppleScript' action that does all the work interacting with Safari, Finder, and Messages to complete the Workflow, i.e. there is no external script just the AppleScript telling the applications what to do. I have now had seven straight days of five triggerings of the 'Open File' Alert in Calendar where it should only be two, so it is clearly repeatable. I trust that your bug report in addition to mine will spur some action on Apple's part.


Thanks again.

Mar 23, 2022 7:13 PM in response to paulcrawford

I also have recreated the Calendar Alarm with Automator, with the only content being an AppleScript that gathers info from Covid websites, which runs nightly at 8pm. No results yet. But given your results I’m not optimistic for a solution. In my case there is only one trigger per day, and one extra trigger within 30 minutes. I have not reported this to Apple. I’d welcome instructions on where to do that.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator workflow triggered by Calendar event runs unexpectedly

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.