View Single Post
If you simply wanted the DUE date to be a certain number days after the START date, then you could do something like this:

Code:
set DAYS_FROM_START to 5

--tell application "Finder" to set theFile to (first item of (selection as list)) as alias
tell application "Finder" to set file_name to (POSIX path of theFile)

set dteBase to current date

set theNote to "Scanned " & (dteBase as string) & " 

"
set projectname to "Factures à Encoder"

set ContextName to "En-Ligne"

set theTask to "Encoder: \"" & file_name & "\""

tell application "OmniFocus"
	set task_title to theTask
	tell default document
		-- GET A REFERENCE TO AN EXISTING PROJECT (OR NEW) PROJECT 
		set lstProj to flattened projects where name = projectname
		if lstProj ≠ {} then
			set oProj to item 1 of lstProj
		else
			set oProj to (make new project with properties {name:projectname})
		end if
		
		-- GET A REFERENCE TO AN EXISTING (OR NEW) CONTEXT
		set lstContexts to flattened contexts where name = ContextName
		if lstContexts ≠ {} then
			set oContext to item 1 of lstContexts
		else
			set oContext to (make new context with properties {name:ContextName})
		end if
		
		-- MAKE A NEW TASK UNDER THE SPECIFIED PROJECT, 
		-- ATTACHING IT TO THE SPECIFIED CONTEXT
		-- AND STAMPING IT WITH A START DATE
		
		set dteStart to dteBase - (time of dteBase) -- zero the time to midnight
		set dteStart to dteStart + (10 * days) -- and add three days
		
		set dteDue to dteStart + (DAYS_FROM_START * days) -- Due N days after start
		
		tell oProj
			tell (make new task with properties {name:task_title, context:oContext, start date:dteStart, due date:dteDue, flagged:true})
				set its note to theNote
				tell its note to make new file attachment with properties {file name:file_name, embedded:true}
			end tell
		end tell
	end tell
end tell