The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Selecting item in quick entry (http://forums.omnigroup.com/showthread.php?t=25424)

Nicholas Riley 2012-09-10 04:04 PM

Selecting item in quick entry
 
I was writing a script that could be used as a PDF Service to add a corresponding task in OmniFocus. The main difference from other similar scripts is that it shows up in Quick Entry so I can add more information to the task.

I got most of the way fine, but ran into some issues with OmniFocus's selection model. Is there a better way to get from an item to a leaf?

This is what I've got right now, with a comment showing where I tried something that seemed more reasonable (but which didn't work):

[CODE]on open _items
local _item, _name, _task
repeat with _item in (_items as list)
tell application "System Events"
set _name to _item's name
get _item's name extension
if (result ≠ "") then -- strip extension
set _name to (characters 1 thru ((count _name's characters) - (count result's characters) - 1) of _name) as string
end if
end tell

tell application "OmniFocus"
tell front document's quick entry
open
set _task to (make inbox task with properties {name:_name})
tell _task's note to make new file attachment with properties ¬
{file name:_item's POSIX path, embedded:true}
get _task's id
-- get leaves whose id is result
-- error "Can’t get id whose it = \"m75YwCmFP4l\". Access not allowed." number -1723
repeat with _leaf in leaves
if _leaf's id is result then
select _leaf
exit repeat
end if
end repeat
end tell
activate
end tell
end repeat
end open[/CODE]

whpalmer4 2012-09-10 05:02 PM

Try this as your inner bit:
[code]

tell front document's quick entry
open
set _task to (make inbox task with properties {name:_name})
tell _task's note to make new file attachment with properties ¬
{file name:_item's POSIX path, embedded:true}
select (leaves whose id is _task's id)
end tell
[/code]

Nicholas Riley 2012-09-15 06:13 AM

[QUOTE=whpalmer4;114396]Try this as your inner bit:
[code]

tell front document's quick entry
open
set _task to (make inbox task with properties {name:_name})
tell _task's note to make new file attachment with properties ¬
{file name:_item's POSIX path, embedded:true}
select (leaves whose id is _task's id)
end tell
[/code][/QUOTE]

Perfect, thanks.


All times are GMT -8. The time now is 10:47 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.