Drafts Action Directory

Remind Me of… Draft

Posted by nahumck, Last update 3 months ago - Unlisted

Creates a reminder with a link back to the draft, setting a due date and time for the reminder.

Note: This can use the following apps: Reminders, GoodTask, Things, Todoist, and OmniFocus.. Disable the Reminders script step and enable the task manager of choice. (swipe to the left to bring up the option to disable) Format of the output is unique to each task manager.

Install

Steps

  • script

    // check to see if draft is blank
    var content = draft.content;
    var check = content.length;
    
    if (content.length == 0) {
    	alert("Draft is blank");
    	context.cancel("Draft was blank");
    }
    
    // Get link to draft
    var url = draft.permalink;
    
    // Prompt for date with toggle for reminder
    var p = Prompt.create();
    p.title = "Select Date";
    p.addTextField("title", "Title", draft.title);
    p.addDatePicker("due","Select Due Date", new Date(),{"mode":"dateAndTime","minuteInterval":5});
    //p.addSwitch("switch","Add an alert?", false);
    p.addButton("Create Task");
    var con = p.show();
    
    var title =  p.fieldValues["title"];
    var due = p.fieldValues["due"];
  • script

    //Create Task in Reminders
    
    var list = ReminderList.findOrCreate("Inbox")
    var alarm = Alarm.alarmWithDate(due);
    var reminder = list.createReminder();
    reminder.title = title;
    reminder.dueDate = due;
    reminder.addAlarm(alarm)
    reminder.notes = url;
    reminder.update();
  • script (disabled)

    // Create Task in GoodTask
    
    if (con) {
    	// goodtask3://add?title=[prompt:Title]&list=[prompt:List Name]&due=[prompt:Due Date]&dueAfter=[prompt-num:Due after]&alarm=[prompt-num:Alarm]&priority=[prompt-num:Priority]&url=[prompt:URL]&notes=[prompt:Notes]
    	const baseURL = "goodtask3://x-callback-url/add/";
    	var cb = CallbackURL.create();
    	cb.baseURL = baseURL;
    	cb.addParameter("title", title);
    	cb.addParameter("list", "Inbox");
    	cb.addParameter("due", due.toString("yyyy-MM-dd HH:mm"));
    	cb.addParameter("alarm", 1);
    	cb.addParameter("url", url);
    	// open and wait for result
    	var success = cb.open();
    	if (success) {
    		console.log("Event created");
    	}
    	else { // something went wrong or was cancelled
    	  	console.log(cb.status);
    	  	if (cb.status == "cancel") {
    			context.cancel();
    		}
    		else {
    			context.fail();
    		}
    	}
    }
    else {
    	context.cancel();
    }
  • script (disabled)

    // Create Task in Things
    if (con) {
    	var todo = TJSTodo.create();
    	todo.title = title;
    	todo.when = due;
    	todo.notes = url;
    	var container = TJSContainer.create([todo]);
    	// Use CallbackURL object to open URL in Things.
    	var cb = CallbackURL.create();
    	cb.baseURL = container.url;
    	var success = cb.open();
    	if (success) {
    		console.log("Task created in Things");
    	}
    	else {
    		context.fail();
    	}
    }
    else {
    	context.cancel();
    }
  • script (disabled)

    // Add Task in Todoist
    
    // Create Todoist credentials
    var credential = Credential.create("Todoist", "Todoist API");
    credential.addTextField("token", "Token");
    credential.authorize();
    
    // Create variables for quick add
    var text = "["+title+"]("+url+")";
    var note = "";
    var reminder = due.toString("dd/MM/yyyy HH:mm")
    
    // Create Task in Todoist
    let todoist = Todoist.create();
    let task = todoist.quickAdd(text, note, reminder);
  • script (disabled)

    // Create Task in OmniFocus
    if (con) {
    	var cb = CallbackURL.create();
    	cb.baseURL = 'omnifocus://x-callback-url/add';
    	cb.addParameter('name',title);
    	cb.addParameter('due',due);
    	cb.addParameter('note',url);
    	var success = cb.open();
    	if (success) {
    		console.log("Task created in OmniFocus");
    	}
    	else {
    		context.fail();
    	}
    }
    else {
    	context.cancel();
    }
  • script (disabled)

    if (con) {
    	var cb = CallbackURL.create();
    	cb.baseURL = 'fantastical2://x-callback-url/parse/';
    	cb.addParameter("title", title);
    	cb.addParameter("due", due.toString("yyyy-MM-dd HH:mm"));
    	cb.addParameter("reminder", 1);
    	cb.addParameter("add", 1);
    	cb.addParameter("url", url);
    	var success = cb.open();
    	if (success) {
    		console.log("Task created in Fantastical");
    	}
    	else {
    		context.fail();
    	}
    }
    else {
    	context.cancel();
    }

Options

  • After Success Default
    Notification Info
    Log Level Error
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.