Action
Add Single Thing
Send a single task with a note to a specific area in a prompt.
Steps
-
script
// Single Task script // List of specified areas var areas = [ "Singles", "Self", "Home/Family", "Finance", "Reminders", ]; // If text is selected, use as task name // Otherwise, leave it blank var sel = editor.getSelectedText() if (sel.length == 0) { var task = ""; } else { var task = sel; }
-
script
/* ---- Prompt ---- */ var p = Prompt.create(); p.title = "Task to Things"; p.addTextField("task", "Task", task, {"autocapitalization":"sentences"}); p.addTextView("note", "Note", "", {"autocapitalization":"sentences","height": 50}); p.addSelect("area", "Area", areas, [""], false); p.addDatePicker("when","When", new Date(), {"mode":"date"}); p.addButton("Send to Things"); var con = p.show();
-
script
// Action if prompt is run if (p.buttonPressed == "Send to Things") { // Pull values from prompt var task = p.fieldValues["task"]; var note = p.fieldValues["note"]; var area = p.fieldValues["area"]; var when = p.fieldValues["when"]; // Create task for Things var todo = TJSTodo.create(); todo.title = task; todo.when = when; todo.notes = note; todo.list = area; todo.tags = ["Singles"]; 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(); }
Options
-
After Success Nothing Notification Error Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.