×

Plug-In: Sort Active Tasks by Creation Date

Places on the clipboard a list of Markdown links to all active tasks sorted by creation date. Use the “Clipboard to Bear” plug-in to send the clipboard contents to a new note in the Bear app.

Return to: OmniFocus Plug-In Collection

Active Tasks Sorted by Creation Date
 

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.links-to-active-task-sorted-by-creation", "version": "1.0", "description": "Places on the clipboard a list of Markdown links to all active tasks sorted by creation date.", "label": "Tasks Sorted by Creation", "shortLabel": "Tasks Sorted by Creation" }*/ (() => { var action = new PlugIn.Action(function(selection, sender){ // action code // selection options: tasks, projects, folders, tags, allObjects var tasks = flattenedTasks tasks.sort((a, b) => { var x = a.added; var y = b.added; if (x < y) {return -1;} if (x > y) {return 1;} return 0; }) var taskData = new Array() tasks.forEach(task => { if(task.active && task.project === null){ var taskTitle = task.name var taskAdded = task.added var dc = Calendar.current.dateComponentsFromDate(taskAdded) var dateSlug = dc.month + "/" + dc.day + "/" + dc.year var taskID = task.id.primaryKey var taskLink = `[${dateSlug} ${taskTitle}](omnifocus:///task/${taskID})` taskData.push(taskLink) } }) var markdownText = taskData.join("\n") Pasteboard.general.string = markdownText new Alert("Completion","Markdown links are on the clipboard.").show() }); action.validate = function(selection, sender){ // validation code // selection options: tasks, projects, folders, tags, allObjects return true }; return action; })();