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.1", "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", "paletteLabel": "Tasks Sorted by Creation" "image": "rectangle.stack", }*/ (() => { const action = new PlugIn.Action(function(selection, sender){ 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; }) taskData = new Array() tasks.forEach(task => { if(task.active && task.project === null){ taskTitle = task.name taskAdded = task.added dc = Calendar.current.dateComponentsFromDate(taskAdded) dateSlug = dc.month + "/" + dc.day + "/" + dc.year taskID = task.id.primaryKey taskLink = `[${dateSlug} ${taskTitle}](omnifocus:///task/${taskID})` taskData.push(taskLink) } }) markdownText = taskData.join("\n") Pasteboard.general.string = markdownText new Alert("Completion","Markdown links are on the clipboard.").show() }); action.validate = function(selection, sender){ return true }; return action; })();