1
tell application "Reminders"
    set newReminder to make new reminder
    set name of newReminder to "Text"
    set due date of newReminder to current date
end tell

How can I set the name of newReminder to input text?

  • I've updated my answer to address your comment. – user3439894 Sep 2 '16 at 18:49
1

Here's an AppleScript code example:

set newReminderName to ""
repeat until newReminderName is not ""
    set newReminderName to text returned of (display dialog "Enter a name for the reminder:" buttons {"Cancel", "OK"} default button 2 default answer "" with icon 1)
    if newReminderName is not "" then
        tell application "Reminders"
            set newReminder to make new reminder
            set name of newReminder to newReminderName
            set due date of newReminder to current date
        end tell
    end if
end repeat

This is coded so that you either have to enter a name for the reminder or cancel the prompt. In other words, if you don't type a name and click OK, you're prompted again and again until you do, or click Cancel.


Updated to address a point mentioned in comment:

The code below is used in an Automator service where the selected text passed to the Automator service becomes the name of the new reminder. It is coded not to create the reminder if an empty sting is passed. Although I don't think it can be triggered unless some text is selected, nonetheless it's always best to include some form of error checking.

on run {input}
    set newReminderName to input
    if newReminderName is not "" then
        tell application "Reminders"
            set newReminder to make new reminder
            set name of newReminder to newReminderName
            set due date of newReminder to current date
        end tell
    end if
end run

enter image description here

  • this is excellent and I love it. If possible without the dialog, and to have my selected text as its name automatically, thank you. – user5154841 Sep 2 '16 at 18:12
  • This is exactly what i had in mind, thank you so much, made my day. – user5154841 Sep 2 '16 at 19:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .