Action

Snooze

Posted by Chris Grieser (armenaton), Last update about 2 months ago

UPDATES

about 2 months ago

added today’s date in the snooze menu

show all updates...

about 2 months ago

added today’s date in the snooze menu

2 months ago

added display of weekday

4 months ago

as the NLP is too unreliable, changed the NLP-textfield for the date to a date picker

ATTENTION: This action only works with a shortcut and some specific settings. Alone, this action will not function as intended.

Look at the Setup Instructions.


Snooze a draft by sending it to Reminders. Set the due date to the date when your task should re-appear in Drafts.

Steps

  • script

    let title = draft.processTemplate("[[title]]");
    let notes = draft.processTemplate("[[body]]");
    
    let f = () => {
    	let lists = ReminderList.getAllReminderLists();
    	
    	let p = Prompt.create();
    
    
    	var today = new Date();	
    	var tomorrow = new Date();
    	tomorrow.setDate(today.getDate() + 1);
    
    	var dd = String(today.getDate()).padStart(2, '0');
    	var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
    	var yyyy = today.getFullYear();
    	const weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    	var weekday_today = weekdays [today.getDay()];
    	var full_date = weekday_today + ", " + dd + '.' + mm + '.' + yyyy;
    	
    
    	p.title = "Snooze"
    	p.message = "Today is: " + full_date;
    	p.addDatePicker("dueDate", "due date", tomorrow, { "mode": "date" });
    	p.addTextField("title", "Title", title, { "wantsFocus": true });
    	p.addTextView("notes", "Notes", notes, {});
    	
    	p.addButton("Create Reminder");
    	if (!p.show()) {
    		return 1;
    	}
    	
    //Set the list to which you want to send the draft. The order of lists in the Reminders App is used, with 0 being the first, 1 the second, 2 the third, etc. 
    	let list = lists[0]; // <-- this number
    	let rem = list.createReminder();
    	
    	rem.title = p.fieldValues["title"];
    	rem.notes = p.fieldValues["notes"];
    	rem.dueDate = p.fieldValues["dueDate"];
    	rem.dueDateIncludesTime = false;
    	
    	if (rem.update()) {
    		console.log("Reminder created");
    app.displayInfoMessage("Draft snoozed");
    	}
    	else {
    		console.log("Error creating reminder");
    		return -1;
    	}
    	return 0;
    }
    
    let result = f();
    switch (result) {
    	case -1: context.fail(); break;
    	case 1: context.cancel(); break
    }

Options

  • After Success Archive , Tags: snoozed
    Notification Error
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.