Plug-In: Append to Note ![Plug-in is compatible with Apple Vision Pro Apple Vision Pro]()
This action will append the provided text to the end of the note of the current task, and includes an option to preface the added text with a localized date/time stamp.
Return to: OmniFocus Plug-In Collection
Append to Note
/*{"type": "action","targets": ["omnifocus"],"author": "Otto Automator","identifier": "com.omni-automation.of.append-to-note","version": "1.5","description": "This action will append the provided text to the end of the note of the current task or project.","label": "Append to Note","shortLabel": "Append to Note","image": "line.horizontal.3.circle"}*/(() => {var action = new PlugIn.Action(async function(selection, sender){// action code// selection options: tasks, projects, folders, tags, allObjectstry {var item = selection.databaseObjects[0]textInputField = new Form.Field.String("textInput",null,null)checkSwitchField1 = new Form.Field.Checkbox("shouldIncludeTimeStamp","Include date/time stamp",true)menuItems = ["Nothing","Single Space", "Double Space","Single Line","Double Line"]spacingItems = [""," "," ","\n","\n\n"]menuIndexes = [0,1,2,3,4]menuElement = new Form.Field.Option("spacingMethod","Prepend with",menuIndexes,menuItems,4)menuElement.allowsNull = falseinputForm = new Form()inputForm.addField(textInputField)inputForm.addField(menuElement)inputForm.addField(checkSwitchField1)inputForm.validate = function(formObject){inputText = formObject.values['textInput']return ((!inputText)?false:true)}formPrompt = "Enter text to append to note:"buttonTitle = "Continue"formObject = await inputForm.show(formPrompt,buttonTitle)var textValue = formObject.values['textInput']shouldIncludeTimeStamp = formObject.values['shouldIncludeTimeStamp']spacingMethodIndex = formObject.values['spacingMethod']if(shouldIncludeTimeStamp){timeStamp = new Date().toLocaleString()textValue = timeStamp + "\n" + textValue}prependText = spacingItems[spacingMethodIndex]if(app.userVersion < new Version("4")){item.appendStringToNote(prependText + textValue)} else {noteObj = item.noteTextstyle = noteObj.styleForRange(noteObj.range)newTextObj = new Text(prependText + textValue, style)noteObj.append(newTextObj)}}catch(err){if(!causedByUserCancelling){new Alert(err.name, err.message).show()}}});action.validate = function(selection, sender){return (selection.databaseObjects.length === 1 &&selection.tasks.length === 1 ||selection.projects.length === 1)};return action;})();