Sending the current Headline to OmniFocus

For the final piece on my series on using AppleScript to add information to OmniFocus, I'm going to describe how to send news items from NetNewswire. It ended up being a lot simpler than I thought that it was going to be.

The hardest part was getting an object for the selected headline. I must be missing something, because I couldn't find this in the NetNewswire dictionary, but a Google search turned up the solution: use the selectedHeadline property. It, in turn, has many properties, of which the title and URL are of particular interest. These values are set into variables to send to OmniFocus later:

tell application "NetNewsWire"
    tell selectedHeadline
        set t to title
        set u to URL
    end tell
end tell

From there, it's the standard code to create a new task in OmniFocus:

tell application "OmniFocus"
    tell default document
        set theProject to project "Follow Up"
        set theContext to context "Online"
            of context "Mac" of context "Home"
        set newTask to make new inbox task with properties
            {name:t, note:u, context:theContext}
        set assigned container of newTask to theProject
		
        compact
    end tell
end tell

And that's it!

While I'm by no means an AppleScript expert at this point, I definitely know enough to get stuff done using AppleScript. I think I'm missing something in that I couldn't find out how to get the currently selected headline on my own (and I have had similar issues with other research this week), but in time I'm sure that I'll get it down.