Action

Add Single Reminder

Posted by nahumck, Last update over 5 years ago - Unlisted

Create a single task to Reminders with a note to a specific list from a prompt (no draft required).

Steps

  • script

    // Single Task to Reminders
    
    /*--- Lists ---*/
    
    var names = ReminderList.getAllReminderLists();
    let lists = names.map(name => name.title);
    lists = lists.sort();
    // if you would like to target specific lists, comment out the above and use the below syntax
    //var lists = ["Inbox","Personal","Home","Health","Finance"];
  • script

    /*--- Prompt ---*/
    
    var p = Prompt.create();
    p.title = "Select Date";
    p.addTextField("title", "Title", "", {"placeholder":"Enter Task"});
    p.addDatePicker("due","Select Due Date & Time", new Date(), {"mode":"dateAndTime","minuteInterval":5});
    p.addSwitch("switch","Add Alarm?", true);
    p.addSelect("list", "List", lists, ["Inbox"], false);
    p.addButton("Send to Reminders");
    var con = p.show();
    
    var title =  p.fieldValues["title"];
    var due = p.fieldValues["due"];
    var list = p.fieldValues["list"];
    var alarm = "";
  • script

    /*--- Create Task in Reminders ---*/
    if (con) {
    	var list = ReminderList.findOrCreate(list)
    	var reminder = list.createReminder();
    	reminder.title = title;
    	reminder.dueDate = due;
    	if (p.fieldValues["switch"] == true) {
    		var alarm = Alarm.alarmWithDate(due);
    		reminder.addAlarm(alarm)
    	}
    	reminder.update();
    }
    else {
    	context.cancel();
    }

Options

  • After Success Nothing
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.