Omnifocus automation: add date into note

Hello,

Discovering the very nice Complete and Await Reply plug-in from Rosemary Orchard, I would like to add automatically the date of the day in the field note of the duplicated task to keep track of the date I send the message for which I’m awaiting reply, for example.

I’m not sure how I would have to modify the javascript to edit field of the task and add a date.

Thanks a lot to anyone who can give me a pointer for this!

All the best,

Gabriel

1 Like

I don’t know JavaScript, but this is what I have. Works great.
Replace with your tag.

/*{
	"author": "Rosemary Orchard",
	"targets": ["omnifocus"],
	"type": "action",
	"identifier": "com.rosemaryorchard.omnifocus.complete-and-await-reply",
	"version": "1.0",
	"description": "Mark the currently selected task as complete and add a new task to await the reply.",
	"label": "Complete and Await Reply",
	"mediumLabel": "Complete and Await Reply",
	"paletteLabel": "Complete and Await Reply",
}*/
(() => {
	let action = new PlugIn.Action(function(selection) {
		let duplicatedTasks = new Array()
		selection.tasks.forEach(function(task){
			insertionLocation = task.containingProject
			if(insertionLocation === null){insertionLocation = inbox.ending}
			dupTasks = duplicateTasks([task], insertionLocation)
			dupTasks[0].name = "Waiting on reply: " + task.name;
			duplicatedTasks.push(dupTasks[0].id.primaryKey);
			task.markComplete();
			dupTasks[0].addTag(tagNamed('Waiting'));
			dupTasks[0].note = "Posted: " + new Date().toLocaleDateString() + ' at ' + new Date().toLocaleTimeString()
		});
		idStr = duplicatedTasks.join(",")
		URL.fromString("omnifocus:///task/" + idStr).open()
    });

    
	action.validate = function(selection){
		return (selection.tasks.length >= 1)
	};
        
	return action;
})();

I’ve wanted to finish this script for a long time (thanks to Rosemary Orchard), as Kurt Clifton originally did it, and then I saw your post and decided to make it for myself and share it with you.

ps: i don’t speak english, sorry - google translator. ¯ \ _ (ツ) _ / ¯

Great, @novmax! Thanks a lot, it works exactly as I wanted! 👍