Looking for a script that does the following:

Hi!

Does anyone have a script that automatically adds a set tag when a task is flagged and ALSO removes that same tag if a task is un-flagged?

Here is something that might work for you (you’ll need to save it as a .omnijs plug-in file):

var flaggedTag = tagNamed("Urgent") //Replace 'Urgent' with the name of the tag you want to use

flattenedTasks.forEach(task => {
	if (task.flagged && !task.completed){
		task.addTag(flaggedTag)
	} else if (!task.flagged && !task.completed && task.tags.includes(flaggedTag)){
		task.removeTag(flaggedTag)
	}
})

Be aware that this only acts on tasks that are uncompleted and that are directly flagged—meaning if a task is just inside of a flagged project and inheriting the flagged status of the project, it is ignored. If you want to change that replace all instances of task.flagged with task.effectivelyFlagged.

If you need help turning that into a plug-in you can install or if you’d like learn how to edit that to do things a bit differently, check out these links:

2 Likes

Thank you so much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.