Automatically add a tag based on a word in task name

Hi! Is there a way to have OF automatically add a tag “Phone” if the word “Call” is in a task name? Thanks!

Automatically not immediately.

The simplest way is to run the following plugin from time to time.

/{
“type”: “action”,
“targets”: [“omnifocus”],
“author”: “Your Name”,
“identifier”: “com.yourname.add-phone-tag-to-all-active-call-tasks”,
“version”: “1.0”,
“description”: “This action searches all active tasks in the database for the word ‘Call’ in their name and adds a ‘Phone’ tag if not already present, then shows an alert when done.”,
“label”: “Add Phone Tag to All Active Call Tasks”,
“shortLabel”: “Add Phone Tag to All”
}
/
(() => {
var action = new PlugIn.Action(function(sender){

    var phoneTag = flattenedTags.byName("Phone") || new Tag("Phone");

    flattenedTasks.forEach(function(task){
        if (task.name.includes("Call") && !task.tags.includes(phoneTag) && task.taskStatus !== Task.Status.Completed && task.taskStatus !== Task.Status.Dropped) {
            task.addTag(phoneTag);
        }
    });

    var alert = new Alert("Process Complete", "All applicable tasks have been updated.");
    alert.show(function(result){});
});

action.validate = function(sender){
    // Always return true since no selection is required
    return true;
};

return action;

})();

Save that in a file with the extension .omnifocusjs and then e.g. add a keyboard shortcut to it in OF.

1 Like

There could be a change of having an Apple Shortcut that does the same and is triggered automatically by time. It should be possible to trigger such a Shortcut without user interaction.
Get back to me if you wanna try this.

Is there a reason you want do this?

You can create a perspective which shows all tasks which contain certain words e.g. call, phone, FaceTime…

1 Like