Applescript Duplicate command: how to use it?
Hi,
I would need some help to use the duplicate command to duplicate a single task. Here is what I got so far: The [...] is the not relevant code that has been stripped out [code] property WForContext : "WFor" tell application "OmniFocus" -- [...] tell front document tell document window 1 set theSelectedItems to selected trees of content end tell end tell set theSelectedTask to value of item 1 of theSelectedItems set MyDoc to first document tell MyDoc -- [...] set contextList to complete WForContext as context maximum matches 1 -- [..] set theWForContext to context id (id of item 1 of contextList) -- PROBLEM: what is the "to" arg expecting? -- (Arg that is optional according to the doc, but is expected by OF - Bug filled to support Ninjas) set theResult to duplicate (theSelectedTask) to (after last task) with properties {context:theWForContext} -- [..] end tell -- [..] end tell [/code] Any help would be greatly appreciated. |
At 'at' needs to be a fully fledge location specifier relative to the enclosing 'tell' block. Right now (at least) a 'document' doesn't really have tasks -- that the relationship exists is an implementation details to make 'id' specifiers work nicely. Sadly, there isn't a good way to document this in the suite.
With a task selected in project mode, this works for me. Of course, this will fail if you have an inbox task, project, or collation group selected. Also, you might want it to copy inside the parent task group if any, but this is a starting point =) It looks like the 'with properties' isn't working on 'duplicate' right now. I've logged a bug on this. [code] tell application "OmniFocus" tell default document tell document window 1 set theSelectedItems to selected trees of content end tell set theSelectedTask to value of item 1 of theSelectedItems set theResult to duplicate theSelectedTask to end of tasks of containing project of theSelectedTask with properties {context:context "cc"} end tell end tell [/code] |
Thanks a lot Tim.
I will be watching the release notes for the fix. |
The line [code]set theResult to duplicate theSelectedTask to end of tasks of containing project of theSelectedTask[/code] does also not set the variable theResult.
Could you fix that? Do you prefer that I fill a formal bug report? |
[QUOTE=Lutin;23449]The line [code]set theResult to duplicate theSelectedTask to end of tasks of containing project of theSelectedTask[/code] does also not set the variable theResult.
Could you fix that? Do you prefer that I fill a formal bug report?[/QUOTE] Thanks! I've written this one up; <bug://bugs/42532> ('duplicate' doesn't return the result) |
These problems should be fixed in 93614.
|
Thanks a lot.
My script is now working (cf. [URL=http://forums.omnigroup.com/showthread.php?p=23705#post23705]this post[/URL]). |
All times are GMT -8. The time now is 08:35 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.