Plug-In: Task with Tasks

Based upon a Rosemary Orchard workflow demonstrated at Learn OmniFocus, this plug-in creates a new task with the specified sub-tasks. Empty fields will be ignored.

Task with Tasks (Tag Group)

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.task-with-tasks", "version": "1.2", "description": "This plug-in creates a new task with the specified sub-tasks.", "label": "New Task with Tasks", "shortLabel": "Task with Tasks" }*/ (() => { var action = new PlugIn.Action(function(selection, sender){ try { // action code // selection options: tasks, projects, folders, tags, allObjects var textInputField01 = new Form.Field.String( "main-task", "Main Task", null ) var textInputField02 = new Form.Field.String( "sub-task-1", "Sub-Task", null ) var textInputField03 = new Form.Field.String( "sub-task-2", "Sub-Task", null ) var textInputField04 = new Form.Field.String( "sub-task-3", "Sub-Task", null ) var textInputField05 = new Form.Field.String( "sub-task-4", "Sub-Task", null ) var textInputField06 = new Form.Field.String( "sub-task-5", "Sub-Task", null ) var shouldBeSequentialCheckbox = new Form.Field.Checkbox( "shouldBeSequential", "Main task is sequential", false ) var shouldBeCompletedByChildrenCheckbox = new Form.Field.Checkbox( "shouldBeCompletedByChildren", "Main task is completed by children", false ) var inputForm = new Form() inputForm.addField(textInputField01) inputForm.addField(shouldBeSequentialCheckbox) inputForm.addField(shouldBeCompletedByChildrenCheckbox) inputForm.addField(textInputField02) inputForm.addField(textInputField03) inputForm.addField(textInputField04) inputForm.addField(textInputField05) inputForm.addField(textInputField06) var formPrompt = "Enter title for main task and any other sub-tasks:" var buttonTitle = "Continue" var formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ var inputText01 = formObject.values['main-task'] var inputText01Status = (!inputText01)?false:true var validation = (inputText01Status) ? true:false return validation } formPromise.then(function(formObject){ var mainTaskTitle = formObject.values['main-task'] var subTask1Title = formObject.values['sub-task-1'] var subTask2Title = formObject.values['sub-task-2'] var subTask3Title = formObject.values['sub-task-3'] var subTask4Title = formObject.values['sub-task-4'] var subTask5Title = formObject.values['sub-task-5'] var shouldBeSequential = formObject.values['shouldBeSequential'] var shouldBeCompletedByChildren = formObject.values['shouldBeCompletedByChildren'] var task = new Task(mainTaskTitle,inbox.beginning) if(shouldBeSequential === true){task.sequential = true} if(shouldBeCompletedByChildren === true){task.completedByChildren = true} if(subTask1Title){ new Task(subTask1Title,task.ending) console.log(subTask1Title) } if(subTask2Title){ new Task(subTask2Title,task.ending) console.log(subTask2Title) } if(subTask3Title){ new Task(subTask3Title,task.ending) console.log(subTask3Title) } if(subTask4Title){ new Task(subTask4Title,task.ending) console.log(subTask4Title) } if(subTask5Title){ new Task(subTask5Title,task.ending) console.log(subTask5Title) } document.windows[0].perspective = Perspective.BuiltIn.Inbox document.windows[0].selectObjects([task]) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) }) } catch(err){console.error(err)} }); action.validate = function(selection, sender){ // validation code // selection options: tasks, projects, folders, tags, allObjects return true }; return action; })();

Return to: OmniFocus Plug-In Collection