Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RosemaryOrchard/c9a7174c92f8f62a0b52a67f094aad00 to your computer and use it in GitHub Desktop.
Save RosemaryOrchard/c9a7174c92f8f62a0b52a67f094aad00 to your computer and use it in GitHub Desktop.
OmniFocus Automation Action: This will append the provided text to the end of the title of the currently selected task(s)
/*{
"type": "action",
"targets": ["omnifocus"],
"author": "Rosemary Orchard",
"identifier": "com.rosemaryorchard.omnifocus.append-to-task-title",
"version": "1.0",
"description": "This action will append the provided text to the end of the title of the currently selected task(s).",
"label": "Append to Task Title",
"shortLabel": "Append to Task Title",
"image": "plus.rectangle.fill"
}*/
(() => {
var action = new PlugIn.Action(function(selection, sender){
// action code
// selection options: tasks, projects, folders, tags, allObjects
var textInputField = new Form.Field.String(
"textInput",
null,
null
)
var checkSwitchField1 = new Form.Field.Checkbox(
"shouldIncludeTimeStamp",
"Include date/time stamp",
true
)
var inputForm = new Form()
inputForm.addField(textInputField)
var formPrompt = "Enter text to append to note:"
var buttonTitle = "Continue"
var formPromise = inputForm.show(formPrompt,buttonTitle)
inputForm.validate = function(formObject){
inputText = formObject.values['textInput']
return ((!inputText)?false:true)
}
formPromise.then(function(formObject){
var textValue = formObject.values['textInput'].trim()
selection.tasks.forEach(function(task){
task.name = task.name + " " + textValue
})
})
formPromise.catch(function(err){
console.error("form cancelled", err.message)
})
});
action.validate = function(selection, sender){
// validation code
// selection options: tasks, projects, folders, tags, allObjects
return (selection.tasks.length >= 1)
};
return action;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment