Search code examples
applescriptautomator

Fill in URL in a newly created reminder


Since macOS Catalina, Reminders.app offers the possibility to fill in an URL in a reminder.

URL in reminder

  1. Click the Info button, then add or change details.
    ... Irrelevant part of the documentation ...
    • Add a URL: Click the URL field, and type a web address.

Source: https://support.apple.com/guide/reminders/add-a-reminder-from-another-app-on-mac-remn1f735fdc/mac#aria-apd1c83fe5ed6c04:~:text=Add%20a%20URL%3A%20Click%20the%20URL%20field%2C%20and%20type%20a%20web%20address.

I am trying, via Automator and with a bit of AppleScript, to create a reminder based upon a text in Chrome.
The goal would be, from a selected text in Chrome, to add a reminder with the URL of the page the selected text is coming from.

I am able to create the reminder properly, along with the name and the body, but I am struggling to fill in the URL field of a reminder.

I tried:

  • set url of new_reminder to tab_url
    
    which errors with:

    Reminders got an error: Can’t set URL of reminder id "x-apple-reminder://AB572176-9661-48FA-ADCF-795D0A912FED" to "https://stackoverflow.com/questions/ask".

  • set uri of new_reminder to tab_url
    
    which errors with:

    Reminders got an error: Can’t make uri of reminder id "x-apple-reminder://2564FAFB-3825-442C-AAD5-BCA17E354D1B" into type specifier.

The first error makes me wonder if the URL should not be type casted into an URL object somehow?
But I am a bit lost on what I should be trying from here.

The macOS version I am on is 10.15.5 (19F101).


Here is my current AppleScript:

on run {input, parameters}
    tell application "Google Chrome"
        set tab_name to get title of active tab of window 1
        set tab_url to get URL of active tab of window 1
        tell application "Reminders"
            set recipes to list "Recipes"
            tell recipes
                set new_reminder to make new reminder
                set name of new_reminder to tab_name
                set body of new_reminder to input
                (* set ??? of new_reminder to tab_url *)
            end tell
        end tell
    end tell
end run

Solution

  • Sadly, as of today 28 November 2022, the URL property is not accessible in the list of properties of a reminder that AppleScript can set — this was updated with the release of macOS Ventura, that didn't change the situation.

    This is backed up by this piece of AppleScript, giving all the properties of a reminder:

    tell application "Reminders"
        set reminder_properties to properties of first reminder
    end tell
    

    Given the reminder filled in as in the question, example reminder

    This piece of script yields the result:

    {
      id:"x-apple-reminder://XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", 
      creation date:date "Wednesday, 2 September 2020 at 19:49:45", 
      container:list id "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" of application "Reminders", 
      priority:0, 
      name:"Test reminder", 
      remind me date:missing value, 
      completed:false, 
      modification date:date "Wednesday, 2 September 2020 at 19:50:41", 
      due date:missing value, 
      completion date:missing value, 
      flagged:false, 
      body:missing value, 
      allday due date:missing value
    }
    

    Where we can definitely see that the URL filled in the reminder is nowhere to be seen.


    This issue has been shared in Apple Feedback Assistant, with the feedback reference FB9033612.


    All credits for this answer goes to @user3439894


    For what it's worth, I ended up doing this with Shortcuts.