The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   AppleScripting Omni Apps (http://forums.omnigroup.com/forumdisplay.php?f=46)
-   -   A little advice.... (http://forums.omnigroup.com/showthread.php?t=18342)

roontoon 2010-10-03 05:30 AM

A little advice....
 
Hi,

I am working on a folderactions script that will add the text that is dropped into the folder into OmniFocus. I am a fairly new applescripter so please be kind...:D I am having a problem adding a date to any of the date fields. I do have the parsing of my text into my actions but nothing happens with the date fields. TIA

d

[CODE]
tell application "OmniFocus"
tell default document
parse tasks with transport text theText as single task singleTask
set start date of selectedItem to (currDate)
set due date of selectedItem to (currDate)
end tell
end tell[/CODE]

whpalmer4 2010-10-03 01:30 PM

Are you parsing a single task? You can embed your start and due dates directly in the string you hand off to parse tasks:

[code]
tell application "OmniFocus"
set theText to "Call Mom #tomorrow 9am #+2d 9pm"
set singleTask to true
tell default document
parse tasks with transport text theText as single task singleTask
end tell
end
[/code]

See the built-in help for Processing Mail messages for all of the details, including setting context and project.

The problem with your script as you've written it is that you aren't grabbing the value returned from parse tasks and then using it to set the dates. Something like this would work, if you didn't want to use the approach shown above:

[code]
tell application "OmniFocus"
set theText to "Call Mom"
set singleTask to true
tell default document
set myNewTasks to parse tasks with transport text theText as single task singleTask
end tell
set start date of first item of myNewTasks to (current date)
set due date of first item of myNewTasks to (current date) + 4 * days
end tell
[/code]

roontoon 2010-10-03 05:02 PM

Thanks that worked... I would also like to assign a default context and project name to each task processed. I tried to use the lines below but they are throwing an error --- OmniFocus got an error: Can’t make "Building A" into type context.

set context of first item of myNewTasks to "Building A"
set project name of first item of myNewTasks to "Miscellaneous"

Again my poor Applescript skills are evident.

Thanks for the pointer.

d

[code]

tell application "OmniFocus"
tell default document
tell application "OmniFocus"
set theText to "Call Mom"
set singleTask to true
tell default document
set myNewTasks to parse tasks with transport text theText as single task singleTask
end tell
set context of first item of myNewTasks to "Building A"
set project name of first item of myNewTasks to "Miscellaneous"
set start date of first item of myNewTasks to (current date)
set due date of first item of myNewTasks to (current date) + 4 * days
end tell
end tell
end tell

[/code]

roontoon 2010-10-03 05:43 PM

[QUOTE=roontoon;86727]Thanks that worked... [/QUOTE]

Spoke too soon. Yes that code did in fact add the dates as I asked. And in my last post I did try to add a project name and context which threw an error. There is one thing that is now not happening. The remainder of the file was previously being added as notes. Below is a sample of the data that I am working with and while this is a email it is from a propitiatory email system that is sending a form and I cannot change the location of where and how it is sent. I can however script a save as to text file and that is the example one below. I need to add appropriate data that is in the file to appropriate fields but I do need the balance of the file to be place in the notes. I would also like later on to parse out unneeded text that is part of the form.

[CODE]





0631 Computer Repair Request
From:
Lesa Carroll
Subject: --no keyboard
October 1, 2010 12:50:02 PM
Room Number: 123
Item: Keyboard
Only one problem per form
BPI Number: M00882
Describe problem below in detail. Please describe any error messages, if any, and state what programs you were running at the time, if known. PLEASE DO NOT BE VAGUE, THE MORE DETAIL I HAVE THE QUICKER I CAN FIX THE PROBLEM. Problems will be repaired according to when they were received and the severity of the problem.


Group 4: M00882 has no keyboard

"Alas for those who never sing, but die with all their music in them" --Oliver Wendell Holmes

6th Grade Reading
& Yearbook Advisor
Burnett Middle School





[/CODE]


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

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