Action

Smart Task in Things

Posted by @mattbirchler, Last update over 6 years ago - Unlisted

Create complex tasks in Things. The task name must always be on the first line. Additional info needs to be prefixed by a set number of strings followed by a space:

  • “at” or “@“ are for due dates (using Things’ smart time parsing, so “10am tomorrow” works)
  • “tag” or “tags” are for tags
  • “deadline” or “dead” are for deadlines
  • “list” is for projects/lists
  • “note” or “-“ (dash) will create a note
  • All lines that don’t match up with a prefix listed above will be assumed to be a note

Steps

  • script

    var arr = draft.content.split("\n");
    
    var baseURL = "things:///add";
    var addLink = CallbackURL.create();
    addLink.baseURL = baseURL;
    
    
    for (i = 0; i < arr.length; i++) {
    	// The task name
    	if (i == 0) {
    		addLink.addParameter("title", arr[i]);
    	}
    	// The due date
    	else if (arr[i].slice(0,3) == "at " || arr[i].slice(0,3) == "At ") {
    		addLink.addParameter("when", arr[i].slice(3,100));
    	} else if (arr[i].slice(0,2) == "@ ") {
    		addLink.addParameter("when", arr[i].slice(2,100));
    	}
    	// The tags
    	else if (arr[i].slice(0,4) == "tag " || arr[i].slice(0,4) == "Tag ") {
    		addLink.addParameter("tags", arr[i].slice(4,50));
    	} else if (arr[i].slice(0,5) == "tags " || arr[i].slice(0,5) == "Tags ") {
    		addLink.addParameter("tags", arr[i].slice(5,50));
    	}
    	// The list
    	else if (arr[i].slice(0,5) == "list " || arr[i].slice(0,5) == "List ") {
    		addLink.addParameter("list", arr[i].slice(5,50));
    	}
    	// The note
    	else if (arr[i].slice(0,5) == "note " || arr[i].slice(0,5) == "Note ") {
    		addLink.addParameter("notes", arr[i].slice(5,128));
    	} else if (arr[i].slice(0,2) == "- ") {
    		addLink.addParameter("notes", arr[i].slice(2,128));
    	}
    	// The deadline
    	else if (arr[i].slice(0,9) == "deadline " || arr[i].slice(0,9) == "Deadline ") {
    		addLink.addParameter("deadline", arr[i].slice(9,128));
    	} else if (arr[i].slice(0,5) == "dead " || arr[i].slice(0,5) == "Dead ") {
    		addLink.addParameter("deadline", arr[i].slice(5,128));
    	}
    	// Anything else
    	else {
    		addLink.addParameter("notes", arr[i]);
    	}
    };
    
    // alert(addLink);
    
    
    // open and wait for result
    var success = addLink.open();

Options

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