The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > AppleScripting Omni Apps
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
A little advice.... Thread Tools Search this Thread Display Modes
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
 
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
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
 
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

Last edited by roontoon; 2010-10-03 at 05:05 PM.. Reason: claritiy
 
Quote:
Originally Posted by roontoon View Post
Thanks that worked...
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

Last edited by roontoon; 2010-10-03 at 05:48 PM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advice on my structure kinderkouture Applying OmniFocus 7 2012-06-28 11:29 AM
structure advice peterlemer OmniFocus 1 for Mac 1 2010-09-16 10:58 AM
Until OF 2.0, I need Collaboration Advice steve OmniFocus 1 for Mac 1 2007-09-16 03:46 PM
Bookmark advice please mwayne OmniWeb General 4 2006-06-17 10:39 PM


All times are GMT -8. The time now is 05:55 PM.


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