# OmniFocus hook to tag

**URL:** https://discourse.hookproductivity.com/t/omnifocus-hook-to-tag/4217
**Category:** Discussion & Help
**Created:** [December 2, 2021, 12:14pm UTC](https://discourse.hookproductivity.com/t/omnifocus-hook-to-tag/4217 "2021-12-02T12:14:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![llvim](https://discourse.hookproductivity.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@llvim](https://discourse.hookproductivity.com/u/llvim)
#### Post date: [December 2, 2021, 12:14pm UTC](https://discourse.hookproductivity.com/t/omnifocus-hook-to-tag/4217/1 "2021-12-02T12:14:16Z")

</div>

omnifocus hook Get Address scripts can add tag link support

```auto
tell front window of application "OmniFocus"
    try
        set theTrees to selected trees of content
        if (count of theTrees) < 1 then
            set theTrees to selected trees of sidebar
        end if
        if (count of theTrees) < 1 then
            return
        end if
        set theSelection to value of item 1 of theTrees
        
        if class of theSelection is folder then
            set theURI to "omnifocus:///folder/" & id of theSelection
	else if class of theSelection is tag then
	    set theURI to "omnifocus:///tag/" & id of theSelection
        else
            set theURI to "omnifocus:///task/" & id of theSelection
        end if
    end try
end tell

```

---

<div class="post-metadata">

### Author: ![boztek](https://discourse.hookproductivity.com/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@boztek](https://discourse.hookproductivity.com/u/boztek)
#### Post date: [March 16, 2022, 5:02am UTC](https://discourse.hookproductivity.com/t/omnifocus-hook-to-tag/4217/2 "2022-03-16T05:02:01Z")

</div>

Just what I was looking for - works great thanks 🙂
